Hello,
I am trying to use nlm to estimate the parameters that minimize the
following function:

Predict<-function(M,c,z){
+ v = c*M^z
+ return(v)
+ }

M is a variable and c and z are parameters to be estimated.

I then write the negative loglikelihood function assuming normal errors:

nll<-function(M,V,c,z,s){
n<-length(Mean)
logl<- -.5*n*log(2*pi) -.5*n*log(s) - (1/(2*s))*sum((V-Predict(Mean,c,z))^2)
return(-logl)
}

When I put the Mean and Variance (variables with 136 observations) into this
function, and estimates for c,z, and s, it outputs the estimate for the
normal negative loglikelihood given the data, so I know that this works.

However, I am unable to use mle to estimate the parameters c, z, and s. I do
not know how or where the data i.e. Mean (M) and Variance (V) should enter
into the mle function. I have tried variations on

mle(nll,start=list(c=0.01,z=2.1,s=200)) including
mle(nll,start=list(M=Mean,V=Var, c=0.01,z=2.1,s=200))

I keep getting errors and am quite certain that I just have a syntax error
in the script because I don't know how to enter the variables into MLE.

Thanks for your help,
Anita.

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to