Created
December 3, 2017 06:49
-
-
Save WilsonMongwe/1b68d3bca01f78aecbac5eeef8b5f6fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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