Skip to content

Instantly share code, notes, and snippets.

@WilsonMongwe
Created December 3, 2017 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WilsonMongwe/1b68d3bca01f78aecbac5eeef8b5f6fb to your computer and use it in GitHub Desktop.
Save WilsonMongwe/1b68d3bca01f78aecbac5eeef8b5f6fb to your computer and use it in GitHub Desktop.
#This is the code for the negative log likelihood function
#for the JUmp-difusion model
nll_jumps<-function(w)
{
mu=w[1] # drift
s=(w[2]) # diffsuive vol
lam=(w[3]) # jump frequency
mu_j=w[4] # jump size
s_j=(w[5]) # jump volatility
#Case where there are no jumps
m=dnorm(x,mean=mu*delta,sd=s*sqrt(delta))*dpois(0,lam*delta)
#The mixture is cut off at 10
for(n in 1:10)
{
m=m+dnorm(x,mean=(mu*delta+n*mu_j),sd=sqrt(s^2*delta+s_j^2*n))*dpois(n,lam*delta) #likelihood
}
-sum(log(m))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment