Learn R Programming

analogue (version 0.4-0)

residuals.mat: Extract Model Residuals

Description

residuals is a is a generic function which extracts model residuals from objects returned by modeling functions. residuals.mat is a residuals method for mat models.

The abbreviated form of this function is resid.

Usage

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

Arguments

object
an object of class mat.
k
number of analogues to use. If missing, k is chosen automatically as the k that achieves lowest RMSE.
weighted
logical; should the weighted mean of the environment for the "k" modern analogues be used instead of the mean?
...
arguments pass to or from other methods.

Value

  • A list with the following components:
  • residualsnumeric; a vector of model residuals.
  • knumeric; either the user supplied number of analogues used, or the k-closest analogue model with lowest apparent RMSE.
  • weightedlogical; are the residuals from a model where fitted values are the weighted averages of the environment for the k-closest analogues. If FALSE, the residuals are from a model using the average of the environment for the k-closest analogues.

Details

Typical usages are resid(object, k, weighted = FALSE, \dots)

See Also

residuals, mat.

Examples

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

## fit the MAT model using the squared chord distance measure
swap.mat <- mat(swapdiat, swappH, method = "SQchord")

## model residuals
resid(swap.mat) # uses abbreviated form

## model residuals using 10 analogues and
## weighted averages
resid(swap.mat, k = 10, weighted = TRUE)

Run the code above in your browser using DataLab