getK {analogue}R Documentation

Extract and set the number of analogues

Description

An extractor function to access the number of analogues used in particular models. The stored value of k can be updated using setK.

Usage

getK(object, ...)

## S3 method for class 'mat'
getK(object, weighted = FALSE, ...)

## S3 method for class 'bootstrap.mat'
getK(object, which = c("bootstrap", "model"),
     prediction = FALSE, ...)

## S3 method for class 'predict.mat'
getK(object, which = c("model", "bootstrap"),
     ...)

setK(object, weighted = FALSE) <- value

## S3 replacement method for class 'mat'
setK(object, weighted = FALSE) <- value

Arguments

object

an R object; currently only for objects of class mat and class bootstrap.mat.

weighted

logical; extract/set number of analogues for a weighted or un-weighted model?

which

character; which k should be extracted, the one from the model or the one from the bootstrap results?

prediction

logical; should the extracted k be the one that is minimum for the test set (newdata) or the model (object).

...

further arguments to other methods.

value

integer; replacement value for k.

Details

getK is a generic accessor function, and setK<- is a generic replacement function.

Objects of class bootstrap.mat contain several different k's. If no predictions are performed, there will be two k's, one for the model and one from bootstrapping the model. Where predictions are performed with newenv supplied, in addition to the k's above, there will be two k' for the predictions, one for the model-based and one for the bootstrap-based predictions. To select k for the predictions, use prediction = TRUE. Argument which determines whether the model-based or the bootstrap-based k is returned.

Value

For getK, an integer value that is the number of analogues stored for use. The returned object has attributes “auto” and “weighted”. “auto” refers to whether the extracted value of k was set automatically (TRUE) or by the user (FALSE). “weighted” states if the returned value is for a weighted analysis or an un-weighted analysis (FALSE).

For setK<-, the updated object.

Author(s)

Gavin L. Simpson

See Also

mat

Examples

## Imbrie and Kipp Sea Surface Temperature
data(ImbrieKipp)
data(SumSST)
data(V12.122)

## merge training set and core samples
dat <- join(ImbrieKipp, V12.122, verbose = TRUE)

## extract the merged data sets and convert to proportions
ImbrieKipp <- dat[[1]] / 100
ImbrieKippCore <- dat[[2]] / 100

## fit a MAT model
ik.mat <- mat(ImbrieKipp, SumSST, method = "chord")

## How many analogues gives lowest RMSE?
getK(ik.mat)
## note that this value was chosen automatically

## Now set k to be 10
setK(ik.mat) <- 10

## check
getK(ik.mat)


[Package analogue version 0.17-6 Index]