getK {analogue}  R Documentation 
An extractor function to access the number of analogues used in
particular models. The stored value of k
can be updated using
setK
.
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
object 
an R object; currently only for objects of class

weighted 
logical; extract/set number of analogues for a weighted or unweighted 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 ( 
... 
further arguments to other methods. 
value 
integer; replacement value for 
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 modelbased and one for the
bootstrapbased predictions. To select k
for the predictions,
use prediction = TRUE
. Argument which
determines whether
the modelbased or the bootstrapbased k
is returned.
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 unweighted
analysis (FALSE
).
For setK<
, the updated object.
Gavin L. Simpson
## 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)