Learn R Programming

cvTools (version 0.1.1)

cost: Prediction loss

Description

Compute the prediction loss of a model.

Usage

mspe(y, yHat)

rmspe(y, yHat)

mape(y, yHat)

tmspe(y, yHat, trim = 0.25)

rtmspe(y, yHat, trim = 0.25)

Arguments

y
a numeric vector or matrix giving the observed values.
yHat
a numeric vector or matrix of the same dimensions as y giving the fitted values.
trim
a numeric value giving the trimming proportion (the default is 0.25).

Value

  • A numeric value giving the prediction loss.

Details

mspe and rmspe compute the mean squared prediction error and the root mean squared prediction error, respectively. In addition, mape returns the mean absolute prediction error, which is somewhat more robust.

Robust prediction loss based on trimming is implemented in tmspe and rtmspe. To be more precise, tmspe computes the trimmed mean squared prediction error and rtmspe computes the root trimmed mean squared prediction error. A proportion of the largest squared differences of the observed and fitted values are thereby trimmed.

See Also

cvFit, cvTuning

Examples

Run this code
# fit an MM-regression model
library("robustbase")
data("coleman")
fit <- lmrob(Y~., data=coleman)

# compute the prediction loss
mspe(coleman$Y, predict(fit))
rmspe(coleman$Y, predict(fit))
mape(coleman$Y, predict(fit))
tmspe(coleman$Y, predict(fit), trim=0.1)
rtmspe(coleman$Y, predict(fit), trim=0.1)

Run the code above in your browser using DataLab