Displaying 2 results from an estimated 2 matches for "pcs39".
Did you mean:
pc39
2006 Sep 30
1
Gradient problem in nlm
...ving some trouble supplying the gradient function to nlm in R for
windows version 2.2.1.
What follows are the R-code I use:
fredcs39<-function(a1,b1,b2,x){return(a1+exp(b1+b2*x))}
loglikcs39<-function(theta,len){
value<-sum(mcs39[1:len]*fredcs39(theta[1],theta[2],theta[3],c(8:(7+len))) -
pcs39[1:len] * log(fredcs39(theta[1],theta[2],theta[3],c(8:(7+len)))))
a1<-theta[1]; b1<-theta[2]; b2<-theta[3]
df.a1<-sum(-mcs39[1:len] + pcs39[1:len]/(a1+exp(b1+b2*c(8:(7+len)))))
df.b1<-sum( -mcs39[1:len] * exp(b1+b2*c(8:(7+len))) + (pcs39[1:len] *
exp(b1+b2*c(8:(7+len))) ) /(a1+exp(b1+...
2006 Sep 26
1
warning message in nlm
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.27795...