Dear R-Help, I also send the following post by e-mail to you, however I try to post it here aswell. My name is Henrik and I am currently trying to solve a Maximum Likelihood optimization problem in R. Below you can find the output from R, when I use the "BFGS" method: The problem is that the parameters that I get are very unreasonable, I would expect the absolute value of each parameter to be bounded by say 5. (furthermore the variable stdev should be greater than zero). One of the problems seems to be that I need to bound the stdev-variable from below by zero to avoid the NaN:s produced. I unfortunately do not know how to do that. Below "y" is the dataset, to which, I want to fit the parameters. I.e. y is the vector (or R equivalent) of observations. I have also multiplied the log-likelihood function by -1, since I know that R by default minimizes the objective function. I would be very happy if you can come up with some Ideas on what is going wrong in the code below. Thank you for your time! Henrik > data<-read.table(file="c:/users/oukal.csv",header=TRUE) > y<-data$V1 > loglik<-function(estimate,y) + { + lap<-estimate[1] + stdev<-estimate[2] + rev<-estimate[3] + n<-length(y) + + 0.5*n*log(2*pi)+ 0.5*n*log(stdev) + + (1/(2*stdev*stdev))*sum(y-(rev/12)-lag(y)*exp(-lap/12)) + } > > optim(c(4,4,4),loglik,y=y,method="BFGS") $par [1] -4884.34155 445.52350 88.53777 $value [1] -1.910321e+174 $counts function gradient 290 7 $convergence [1] 0 $message NULL There were 50 or more warnings (use warnings() to see the first 50)
-- View this message in context: http://n4.nabble.com/Maximum-Likelihood-Estimation-in-R-tp2018822p2018822.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.