predict.SpectraPoints-method {soil.spec}R Documentation

Predict soil properties from an object of class "SpectraPoints"

Description

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.

Usage

 
## 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", ...)

Arguments

object

object of type "SpectraPoints"

idcol

"character"; ID column name

model

"SpectraModel"; prediction model

variable

"character"; variable name (see 'attributes in spec.env(show.env = TRUE))

output

"SoilProfileCollection"; optional output object where the predicted soil properties can be written

validate

"logical"; runs validation of overlap of points in feature space (see details)

model.class

"character"; prediction model class

confidence.band

"logical"; specifies whether confidence bands should be derived for each prediction

prob.

"numeric"; probability for confidence bands

signif.digits

"integer"; significant digits (all output numbers are typically rounded to three significant digits to save space)

st.wavenumbers

"data.frame"; standard wavenumbers with band names and upper / lower limits (usually predefined)

instr.range

"character"; instrument range

...

other optional arguments

Details

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.

Author(s)

Tomislav Hengl and Andrew Sila

References

See Also

SpectraPoints-class, fit.SpectraModel

Examples

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)

[Package soil.spec version 0.2.0 Index]