[R] Quick Question - MLE for Geometric Brownian Motion Process with Jumps
Dieter Menne
dieter.menne at menne-biomed.de
Sun Apr 5 16:48:22 CEST 2009
John-Paul Taylor <johnpaul.taylor <at> ryerson.ca> writes:
>
>
> 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.
I have not used that function, but the error message is rather clear in
telling you that your start values are not good. Try to plot the function
and the gradient at that point. Sometime moving by a very small amount
helps.
Dieter
More information about the R-help
mailing list