[R] Help with predict.lm

Mike White mikewhite.diu at tiscali.co.uk
Tue Apr 19 14:34:03 CEST 2005


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




More information about the R-help mailing list