predict.pfr | R Documentation |
Takes a fitted pfr
-object produced by {pfr}
and produces predictions given a
new set of values for the model covariates or the original values used for the model fit.
Predictions can be accompanied by standard errors, based on the posterior distribution of the
model coefficients. This is a wrapper function for {predict.gam}
()
## S3 method for class 'pfr'
predict(
object,
newdata,
type = "response",
se.fit = FALSE,
terms = NULL,
PredOutOfRange = FALSE,
...
)
object |
a fitted |
newdata |
a named list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the original data are
returned. All variables provided to newdata should be in the format supplied to |
type |
character; see |
se.fit |
logical; see |
terms |
character see |
PredOutOfRange |
logical; if this argument is true then any functional predictor values in
newdata corresponding to |
... |
additional arguments passed on to |
If type == "lpmatrix"
, the design matrix for the supplied covariate values in long
format. If se == TRUE
, a list with entries fit and se.fit containing fits and standard errors,
respectively. If type == "terms" or "iterms"
each of these lists is a list of matrices of the
same dimension as the response for newdata containing the linear predictor and its se for each term
Mathew W. McLean mathew.w.mclean@gmail.com and Fabian Scheipl
{pfr}
, [mgcv]{predict.gam}
######### Octane data example #########
data(gasoline)
N <- length(gasoline$octane)
wavelengths = 2*450:850
nir = matrix(NA, 60,401)
test <- sample(60,20)
for (i in 1:60) nir[i,] = gasoline$NIR[i, ] # changes class from AsIs to matrix
y <- gasoline$octane
#fit <- pfr(y~af(nir,argvals=wavelengths,k=c(6,6), m=list(c(2,2),c(2,2))),
# subset=(1:N)[-test])
#preds <- predict(fit,newdata=list(nir=nir[test,]),type='response')
#plot(preds,y[test])
#abline(a=0,b=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.