Dear R-users,

I am trying to find the MLEs for a loglikelihood function (loglikcs39) and
tried using both optim and nlm.

fredcs39<-function(b1,b2,x){return(exp(b1+b2*x))}
loglikcs39<-function(theta,len){
sum(mcs39[1:len]*fredcs39(theta[1],theta[2],c(8:(7+len))) - pcs39[1:len] *
log(fredcs39(theta[1],theta[2],c(8:(7+len)))))
}
theta.start<-c(0.1,0.1)


1. The output from using optim is as follow
--------------------------------------------------------------

optcs39<-optim(theta.start,loglikcs39,len=120,method="BFGS")
> optcs39
$par
[1] -1.27795226 -0.03626846

$value
[1] 7470.551

$counts
function gradient
     133       23

$convergence
[1] 0

$message
NULL

2. The output from using nlm is as follow
-----------------------------------------------------------

> outcs39<-nlm(loglikcs39,theta.start,len=120)
Warning messages:
1: NA/Inf replaced by maximum positive value
2: NA/Inf replaced by maximum positive value
3: NA/Inf replaced by maximum positive value
4: NA/Inf replaced by maximum positive value
5: NA/Inf replaced by maximum positive value
6: NA/Inf replaced by maximum positive value
7: NA/Inf replaced by maximum positive value
> outcs39
$minimum
[1] 7470.551

$estimate
[1] -1.27817854 -0.03626027

$gradient
[1] -8.933577e-06 -1.460512e-04

$code
[1] 1

$iterations
[1] 40


As you can see, the values obtained from using both functions are very
similar.  But, what puzzled is the warning message that i got from using
nlm. Could anyone please shed some light on how this warning message come
about and whether it is a cause for concern?


Many thanks in advance for any advice!

singyee

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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