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, ...) setK(object, weighted = FALSE) <- value ## S3 method for class 'mat': setK(object, weighted = FALSE) <- value
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. |
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.
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.
Gavin L. Simpson
## continue the example from join example(join) ## fit a MAT model ik.mat <- mat(ImbrieKipp, SumSST, method = "SQchord") ## 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)