Statistics for Laboratory Scientists ( 140.615 )

Prediction and Calibration

Prediction

Example from class: David Sullivan’s heme data

h2o2 <- rep(c(0,10,25,50), each=3)
pf3d7 <- c(0.3399,0.3563,0.3538,
           0.3168,0.3054,0.3174,
           0.2460,0.2618,0.2848,
           0.1535,0.1613,0.1525)
dat <- data.frame(conc=h2o2, od=pf3d7)

The regression of optical density on hydrogen peroxide concentration.

lm.fit <- lm(od ~ conc, data=dat)
summary(lm.fit)$coef
##                 Estimate   Std. Error   t value     Pr(>|t|)
## (Intercept)  0.353050073 0.0049955194  70.67335 7.844454e-15
## conc        -0.003870984 0.0001759324 -22.00268 8.426407e-10

Predict the optical density at H202 concentration 30.

predict(lm.fit, data.frame(conc=30))
##         1 
## 0.2369206

Predict the optical density at H202 concentrations 20, 30, and 40.

predict(lm.fit, data.frame(conc=c(20,30,40)))
##         1         2         3 
## 0.2756304 0.2369206 0.1982107

Predict the optical density at H202 concentrations 20, 30, and 40, and get the 95% confidence intervals for the mean response.

predict(lm.fit, data.frame(conc=c(20,30,40)), interval="confidence")
##         fit       lwr       upr
## 1 0.2756304 0.2682315 0.2830293
## 2 0.2369206 0.2287800 0.2450611
## 3 0.1982107 0.1877931 0.2086283

Predict the optical density at H202 concentrations 20, 30, and 40, and get the 95% prediction intervals.

predict(lm.fit, data.frame(conc=c(20,30,40)),interval="prediction")
##         fit       lwr       upr
## 1 0.2756304 0.2490074 0.3022533
## 2 0.2369206 0.2100820 0.2637591
## 3 0.1982107 0.1705961 0.2258253

Plot the confidence band for the mean response, and the prediction interval for new observations.

xx <- seq(0, 50, length=101)
predict.mean <- predict(lm.fit, data.frame(conc=xx), interval="confidence")
predict.new <- predict(lm.fit, data.frame(conc=xx), interval="prediction")
par(las=1)
plot(dat$conc, dat$od, xlab="H2O2 concentration", ylab="OD", ylim=range(predict.new), col="lightgrey")
lines(xx, predict.mean[,1], lwd=2)
lines(xx, predict.mean[,2], lty=2)
lines(xx, predict.mean[,3], lty=2)
lines(xx, predict.new[,2], lty=2, col="blue")
lines(xx, predict.new[,3], lty=2, col="blue")

Calibration

Example from class: concentration of quinine in a set of standards

dat <- data.frame(quinine=c( 0, 0, 0, 
                            12,12,12, 
                            24,24,24, 
                            36,36,36),
                  fluor=c(100.45, 98.92,101.33, 
                          133.19,127.33,126.78,
                          152.72,157.43,160.81, 
                          188.73,191.96,183.70))
dat
##    quinine  fluor
## 1        0 100.45
## 2        0  98.92
## 3        0 101.33
## 4       12 133.19
## 5       12 127.33
## 6       12 126.78
## 7       24 152.72
## 8       24 157.43
## 9       24 160.81
## 10      36 188.73
## 11      36 191.96
## 12      36 183.70

Plot the data.

par(las=1)
plot(dat)
abline(lsfit(dat$quinine, dat$fluor), col="blue")

Using the ‘calibrate’ function from the SPH.140.615 package, estimate the concentration corresponding to the fluorescence of 143.70.

library(SPH.140.615)
calibrate(dat$quinine, dat$fluor, 143.70)
##      est       lo       hi 
## 18.03601 14.97447 21.09755

Estimate the concentration on the basis of 3 independent measurements.

newy <- c(148.56, 149.36, 150.29)
calibrate(dat$quinine, dat$fluor, newy)
##      est       lo       hi 
## 20.38325 18.46910 22.29739