Learn R Programming

analogue (version 0.3-3)

k: Extract and set the number of analogues

Description

An extractor function to access the number of analogues used in particular models. Can also be used to set or update the stored value of $k$.

Usage

k(object, ...)

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

## S3 method for class 'bootstrap': k(object, ...)

k(object, weighted=FALSE) <- value

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

Arguments

object
an R object; currently only for objects of class mat and class bootstrap.
weighted
logical; extract/set number of analogues for a weighted or un-weighted model?
...
further arguments to other methods.
value
integer; replacement value for $k$.

Value

  • For k, 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 k<-, the updated object.

Details

k is a generic accessor function, and k<- is a generic replacement function.

See Also

mat

Examples

Run this code
## continue the example from join
example(join)

## fit a MAT model
swap.mat <- mat(swapdiat, swappH, method = "SQchord")

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

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

## check
k(swap.mat)

Run the code above in your browser using DataLab