Description Usage Arguments Details Author(s) References See Also Examples
View source: R/predict.SpectraPoints.R
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.
1 2 3 4 5 6 7 8 9 10 11 12 |
## 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.