Statistics for Laboratory Scientists ( 140.615 )

Prediction and Calibration

Example: 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)
lm.out <- summary(lm.fit)
lm.out$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.

b0.hat <- lm.out$coef[1,1]
b0.hat
## [1] 0.3530501
b1.hat <- lm.out$coef[2,1]
b1.hat
## [1] -0.003870984
s.hat <- lm.out$sigma
s.hat
## [1] 0.01147782
y.hat.30 <- b0.hat+b1.hat*30
y.hat.30
## [1] 0.2369206

Get the 95% confidence interval for the mean optical density at H202 concentration 30.

n <- length(dat$conc)
n
## [1] 12
m <- mean(dat$conc)
m
## [1] 21.25
SXX <- sum((dat$conc-m)^2)
SXX
## [1] 4256.25
y.hat.30 + c(-1,1)*qt(0.975,n-2)*s.hat*sqrt(1/n+(30-m)^2/SXX)
## [1] 0.2287800 0.2450611

Easier:

predict(lm.fit, data.frame(conc=30), interval="confidence")
##         fit     lwr       upr
## 1 0.2369206 0.22878 0.2450611

Get the 95% prediction interval for a new observation at H202 concentration 30.

y.hat.30 + c(-1,1)*qt(0.975,n-2)*s.hat*sqrt(1+1/n+(30-m)^2/SXX)
## [1] 0.2100820 0.2637591

Easier:

predict(lm.fit, data.frame(conc=30), interval="prediction")
##         fit      lwr       upr
## 1 0.2369206 0.210082 0.2637591