On Fri, 10 Apr 2009, From Watchman wrote:
Hi
I have been having issue with a ML estimator for Jump diffusion process but
know I am get little error I didn't notice before like I am try to create a
vector
#GBMPJ MLE Combined Ph 1 LR
#
n<-length(combinedlrph1)
j<-c(1,2,3,4,5,6,7,8,9,10)
Error in c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) :
unused argument(s) (3, 4, 5, 6, 7, 8, 9, 10)
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((for(i in 1:n)(log(sum(for(j
in 1:10)(((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")
Error in c(1, 1, 1, 1, 1) : unused argument(s) (1, 1, 1)
then below in the maxLik it is not seem to be taking my other starting value
and I am not sure why? If anyone can help me that would be great.
I don't have a full solution, but I will point out that for() loops don't do
what I think you think they do:
> sum(for(i in 1:10) i)
[1] 10
Unless n is very large I suspect you can rewrite logLikVal to use outer() and
then sum().
Something else must be badly wrong too, since you shouldn't be able to get that error
message out of base::c(). Try find("c") to see if it has been masked by
something else.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlum...@u.washington.edu University of Washington, Seattle
______________________________________________
R-help@r-project.org 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.