Dear all,

I am comparing two regression models, one by nls() and other by mle() packages.

I know how do plot the estimated values using curve() function, but I need the predicted to use on other functions and I don´t know how do get the predicted value my mle model.

Any help are welcome.

miltinho
Brazil.


----
require(mle)
richness<-c(29,24,17,17,24,27,32,28,22,27,19,27,28,31,23,31,21)
Area<-c(8.56,14.35,5.59,5.13,21.95,16.86,4.76,24.73,3.79,3.96,56.11,45.77,52.27,158.45,19.3,80.01,2.06)
plot(richness~Area)
x <- seq(-3, 3, .01)
ss <- sapply(x, function(A) sum(resid(lm(richness ~ I(Area^A)))^2))
x[which.min(ss)]
aa<-x[which.min(ss)]
par(mfrow=c(1,2))
plot(ss ~ x)

md.lm<-model_power.Area.normal <- lm(richness ~ I(Area^aa))
st <- c(Const = coef(md.lm)[[1]], B = coef(md.lm)[[2]], A = x[which.min(ss)])
model_power.Area.normal.nls<-nls(richness ~ Const+B*(Area^A), st = st)
LL.Poisson.Richness.Area <- function(a1,a2){
 esp <- a1*(Area)^a2                 
 -sum(dpois(x=richness,lambda=esp,log=T))    
 }                                               
st<-coef(model_power.Area.normal.nls)
model_power.Area.poisson.mle<-mle(LL.Poisson.Richness.Area, start=list(a1=(st[[2]]),a2=st[[3]]))
plot(richness~Area)
coefs.nls<-coef(model_power.Area.normal.nls)
curve(coefs.nls[1]+coefs.nls[2]*((x)^coefs.nls[3]),add=T, col="red")
coefs.mle<-coef(model_power.Area.poisson.mle)
curve((coefs.mle[1]*((x)^coefs.mle[2])),add=T, col="black")



 para armazenamento!

	[[alternative HTML version deleted]]

