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
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.