I'm trying to get 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.pred, sd = sigma, log = TRUE) : # element 3 is empty; # the part of the args list of '.Internal' being evaluated was: # (x, mean, sd, log) #SigB>>Error in eval(expr, envir, enclos) : object "sigma" not found Obviously, I'm missing something, but what? Thanks, Cliff ______________________________________________ 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.