[R] Problem with MLE

From: Bazman76 <h_a_patience_at_hotmail.com>
Date: Tue, 17 May 2011 07:49:50 -0700 (PDT)


Hi there,

I am trying to run the following code:

> dcOU<-function(x,t,x0,theta,log=FALSE){

+ Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t)
+ Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2])
+ dnorm(x,mean=Ex,sd=sqrt(Vx),log=log)
+ }

> OU.lik<-function(theta1,theta2,theta3){
+ n<-length(X)
+ dt<-deltat(X)
+ ~sum(dcOU(X[2:n],dt,X[1:(n-1)],c(theta1,theta2,theta3),log=TRUE))
+ }

>
> #ex3.01.R
> require(stats4)

Loading required package: stats4
> require(sde)
Loading required package: sde
Loading required package: MASS
Loading required package: fda
Loading required package: splines
Loading required package: zoo

To check the errata corrige of the book, type vignette("sde.errata")

Attaching package: 'sde'

The following object(s) are masked _by_ '.GlobalEnv':

    dcOU

> set.seed(123)
> X<-sde.sim(model="OU",theta=c(3,1,2),N=1000,delta=1)

T set to = 1000.000000
> mle(OU.lik,start=list(theta1=1,theta2=0.5,theta3=1),
+ method="L-BFGS-B",lower=c(-Inf,0,0))->fit Error in optim(start, f, method = method, hessian = TRUE, ...) :   'pairlist' object cannot be coerced to type 'double'

but there appears to be a problem with the optimisation process? Unfortunately it's not clear to me from the error message what is going wrong?

Can someone please advise.

--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-MLE-tp3529445p3529445.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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.
Received on Tue 17 May 2011 - 15:08:02 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 May 2011 - 15:50:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive