predict.SpectraPoints-method {soil.spec} | R Documentation |
"SpectraPoints"
Predicts soil properties from an object of class "SpectraPoints"
(or a "data.frame"
containing absorbances and sample IDs) either by using a referent "SpectraModel"
(comes with the package) or by using the user created model. Extends, for example, the "predict.mvr"
function available from the pls package.
## S4 method for signature 'SpectraPoints' predict(object, idcol = "SAMPLEID", model, variable = model@variable, output, validate = FALSE, model.class = "mvr", confidence.band = TRUE, prob. = .90, signif.digits = 3, st.wavenumbers=wavenumbers, instr.range = c("ten-mir", "alp-mir", "mpa-nir")[1], ...) ## S4 method for signature 'data.frame' predict(object, idcol = "SAMPLEID", ...)
object |
object of type |
idcol |
|
model |
|
variable |
|
output |
|
validate |
|
model.class |
|
confidence.band |
|
prob. |
|
signif.digits |
|
st.wavenumbers |
|
instr.range |
|
... |
other optional arguments |
When predicting from a data.frame
, column names must contain wavenumbers and first column must contain sample IDs. Validation of overlap in feature space is done using PCs 1-3 derived from absorbance bands. This method basically compares for each new sample shortest distance (in 3D space; derived using spatstat::nncross.pp3
) to the cloud of referent points and then prints warning if the distance is larger than two times the largest nndist
(distance) for the referent point cloud.
Tomislav Hengl and Andrew Sila
Mevik, B.-H., Wehrens, R. (2007) The pls Package: Principal Component and Partial Least Squares Regression in R. Journal of Statistical Software 18(2), 1-24.
SpectraPoints-class
, fit.SpectraModel
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)