# Prediction plots

3 messages
Open this post in threaded view
|

## Prediction plots

 Thanks Boris, the following is an extract of my data. I have developed biomass models using codes like: start <- coef (lm(log(Btot)~I(log(dbh**2*haut)),data=dat[dat\$Btot>0,])) start[1] <- exp(start[1]) names(start) <- c("a","b") M1 <- nls(Btot~a*(dbh**2*haut)**b,data=dat,start=start,weights=1/dat\$dbh**4) start <- coef(lm(log(Btot)~I(log(dbh))+I(log(haut)),data=dat[dat\$Btot>0,])) start[1] <- exp(start[1]) names(start) <- c("a","b1","b2") M2 <- nls(Btot~a*dbh**b1*haut**b2,data=dat,start=start,weights=1/dat\$dbh**4) Tree No dbh haut Btot 1 35.00 18.90 0.535 2 25.00 16.60 0.248 3 23.00 19.50 0.228 4 13.50 15.60 0.080 5 20.00 18.80 0.172 6 23.00 17.40 0.190 7 29.00 19.90 0.559 8 17.60 18.20 0.117 9 31.00 25.30 0.645 10 26.00 23.50 0.394 11 13.00 13.00 0.038 12 32.00 20.70 0.443 It is my interest to get prediction plots for the models. I have tried to use the following codes with no success: Let m be one of the fitted models with dbh as the only entry. To construct a plot of the predictions made by this model I have tried: with(dat,plot(dbh,Btot,xlab="Dbh(cm)",ylab="Biomass (t)")) D <- seq(par("usr")[1],par("usr")[2],length=200) lines(D,predict(m,newdata=data.frame(dbh=D)),col="red") For a model m that has dbh and height as entries, I have tried to get its predictions as follows: D <- seq(0,180,length=20) H <- seq(0,61,length=20) B <- matrix(predict(m,newdata=expand.grid(dbh=D,height=H)),length(D)) Can someone provide help please!!! Best regards, Santiago Bueno         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.