Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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