Learn R Programming

analogue (version 0.4-0)

fitted.mat: Fitted values of a MAT model

Description

Extracts the fitted values for the training set of a MAT model using the, possibly weighted, mean of the environment for the k-closest analogues.

Usage

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

Arguments

object
an object of class mat.
k
numeric; choose which of the k-closest analogue models' fitted values is printed. Overides the default stored in the object returned by fitted.mat.
weighted
logical; should weighted averages be used instead of simple averages?
...
arguments to be passed to other methods.

Value

  • A list with the following components:
  • estimatednumeric; a vector of fitted values.
  • knumeric; this is the k-closest analogue model with lowest apparent RMSE.
  • weightedlogical; are the fitted values the weighted averages of the environment for the k-closest analogues. If FALSE, the fitted values are the average of the environment for the k-closest analogues.

Details

The fitted values are for the training set and are taken as the, possibly weighted, mean of the environmental variable in question across the k-closest analogues. The fitted value for each sample does not include a contribution from itself --- it is the closest analogue, having zero dissimilarity. This spurious distance is ignored and analogues are ordered in terms of the non-zero distances to other samples in the training set, with the k-closest contributing to the fitted value.

See Also

mat for the model fitting function, residuals.mat for extraction of residuals. Related functions are predict.mat for predicting for unknown samples and bootstrap.mat for bootstrap estimates for the training set.

Examples

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

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

## the fitted values:
fitted(swap.mat)

## the fitted values for a MAT model
## with 10 analogues
fitted(swap.mat, k = 10)

Run the code above in your browser using DataLab