[R] Quick Question - MLE for Geometric Brownian Motion Process with Jumps

John-Paul Taylor johnpaul.taylor at ryerson.ca
Sun Apr 5 14:27:34 CEST 2009


Hi All,


I am relatively new to R and having a great experience with it but have come up with a little road block. 

I am tying to run a maxlik regression and keep getting the error,
NA in the initial gradient

My Code is below:
gbmploglik<-function(param){
	mu<-param[1]
	sigma<-param[2]
	lamda<-param[3]
	nu<-param[4]
	gama<-param[5]
	logLikVal<- - n*lamda - .5*n*log(2*pi) + sum(log(sum(for(j in 1:10)(cat((lamda^j/factorial(j))*(1/((sigma^2+j*gama^2)^.5)*exp( - (combinedlrph1-mu-j*nu)^2/2*(sigma^2+j*gama^2))))))))
	logLikVal
}
rescbj<- maxLik(gbmploglik, grad = NULL, hess = NULL, start=c(1,1,1,1,1), method = "Newton-Raphson")

I was wondering if there is something that I have to do with the grad= and maybe put something other then NULL. The other issue is that there might be something wrong with the loglikelihood function, because of the loop that I put in it.

If you have any suggestion or see something incorrect that I am doing please let me know.

Thanks

JP




More information about the R-help mailing list