data(afspec)
## predict pH using absorbances directly:
data(m.PHIHOX)
x <- predict(afspec$ab, model=m.PHIHOX)
## Not run:
# ## how good is this model?
# ## we look at the calibration data used to produce "m.PHIHOX"
# pr <- m.PHIHOX@model$fitted.values
# library(plyr)
# library(scales)
# data(afss)
# afss.tbl <- join(afss$sites, afss$horizons)
# tbl <- merge(data.frame(predicted=pr, SAMPLEID=attr(pr, "names")),
# afss.tbl[,c("SAMPLEID","PHIHOX")])
# v.r <- range(tbl$PHIHOX)
# r.square <- summary(lm(as.formula(paste("PHIHOX ~ predicted - 1")),
# tbl))$adj.r.squared
# plot(x=tbl$predicted, y=tbl$PHIHOX, asp=1, xlim=v.r, ylim=v.r,
# col=alpha("darkgrey", 0.5), xlab="Predicted", ylab="Measured",
# main=paste("R-square:", formatC(r.square, digits=3), sep=""))
# abline(a=0, b=1, lw=2, col="black")
# ## End(Not run)
Run the code above in your browser using DataLab