[R] Help with predict.lm

Liaw, Andy andy_liaw at merck.com
Tue Apr 19 14:53:24 CEST 2005


Will this help?
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/1202.html

[Found by RSiteSearch("calibration") in R-2.1.0.]

Andy

> From: Mike White
> 
> Hi
> I have measured the UV absorbance (abs) of 10 solutions of a 
> substance at
> known concentrations (conc) and have used a linear model to plot a
> calibration graph with confidence limits.  I now want to predict the
> concentration of solutions with UV absorbance results given 
> in the  new.abs
> data.frame, however predict.lm only appears to work for new 
> "conc" variables
> not new "abs" variables.
> 
> I have search the help files and did find a similar problem 
> in June 2000,
> but unfortunately no solution was offered.
> Any help and how to use predict.lm with the new "abs" data to 
> predict "conc"
> with confidence limits would be appreciated.
> 
>     conc<-seq(100, 280, 20) #  mg/l
>     abs<-c(1.064, 1.177, 1.303, 1.414, 1.534, 1.642, 1.744, 
> 1.852, 1.936,
> 2.046) # absorbance units
>     lm.calibration<-lm(abs ~ conc)
>     pred.w.plim <- predict(lm.calibration,  interval="prediction")
>     pred.w.clim <- predict(lm.calibration,  interval="confidence")
>     matplot(conc, cbind(pred.w.clim, pred.w.plim[,-1]),
>              lty=c(1,2,2,3,3), type="l", ylab="abs", xlab= 
> "conc mg/l")
>     points(conc, abs, pch=21, col="blue")
> 
>     new.abs<-data.frame(abs=c(1.251, 1.324, 1.452))
> 
>     predict(calibration.lm, new.abs) # does not work
> 
> 
> Thanks
> Mike White
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>




More information about the R-help mailing list