predict.pcr: Predicted values from a principal components regression

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Calculates predicted values from a fitted principal components regression model. Leave-one-out, bootstrap or n k-fold crossvalidated predictions are also implemented.

Usage

1
2
3
4
5
## S3 method for class 'pcr'
predict(object, newdata, ncomp = object$ncomp,
        CV = c("none", "LOO", "bootstrap", "kfold"),
        verbose = FALSE, nboot = 100, kfold = 10, folds = 5,
        ...)

Arguments

object

a fitted model of class "pcr", the result of a call to pcr.

newdata

data frame of new observations for which predictions are sought.

ncomp

numeric; the PCR components for which predictions are sought. If ncomp = c, predictions for components 1:c are produced.

CV

character; the type of crossvalidation required. Currently, no crossvalidation methods are implemented.

verbose

logical; should progress on crossvalidation be printed to the console?

nboot

numeric; the number of bootstrap samples to draw.

kfold

numeric; the number of folds to split data into.

folds

numeric; the number of repetitions of k-fold CV.

...

arguments passed to other methods.

Details

predict.pcr arranges for any transformation applied to the training data to be applied to the newdata prior to prediction.

Value

A matrix of predicted values with rows representing samples in newdata and columns, the PCR components requested via ncomp.

Author(s)

Gavin L. Simpson

See Also

pcr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Load the Imbrie & Kipp data and
## summer sea-surface temperatures
data(ImbrieKipp)
data(SumSST)

## choose 10 samples to act as a test set, for illustration
take <- c(5,58,31,51,42,28,30,57,8,50)

## normal interface and apply Hellinger transformation
mod <- pcr(ImbrieKipp[-take, ], SumSST[-take], tranFun = Hellinger)

## predictions
predict(mod, ImbrieKipp[take, ], ncomp = 4)

## predictions
set.seed(123)
predict(mod, ImbrieKipp[take, ], ncomp = 4, CV = "bootstrap",
        nboot = 100)

gavinsimpson/analogue documentation built on June 17, 2021, 2:37 a.m.