Displaying 1 result from an estimated 1 matches for "linregfun".
2008 Nov 19
1
mle2 simple question - sigma?
...t started with maximum likelihood estimation with a
simple regression equivalent out of Bolker (Ecological Models and Data
in R, p302).
With this code:
#Basic example regression
library(bbmle)
RegData<-data.frame(c(0.3,0.9,0.6),c(1.7,1.1,1.5))
names(RegData)<-c("x", "y")
linregfun = function(a,b,sigma) {
Y.pred = a+b*x
-sum(dnorm(y,mean=Y.pred,sd=sigma,log=TRUE))
}
SigA<-mle2(linregfun, start=list(a=0.5, b=2), data=RegData)
#Or
SigB<-mle2(y~dnorm(mean=a+b*x,sd=sigma),start=list(a=0.5, b=2),
data=RegData)
I get:
#Messages
#SigA>>Error in dnorm(y, mean = Y.pre...