Computes accuracy measurements.
accuracy(pred, obs, na.rm = FALSE, tol = sqrt(.Machine$double.eps))
a numeric vector with the predicted values.
a numeric vector with the observed values.
a logical indicating whether NA values should be stripped before the computation proceeds.
divide underflow tolerance.
Returns a named vector with the following components:
me
mean error
rmse
root mean squared error
mae
mean absolute error
mpe
mean percent error
mape
mean absolute percent error
r.squared
pseudo R-squared
set.seed(1)
nobs <- nrow(bodyfat)
itrain <- sample(nobs, 0.8 * nobs)
train <- bodyfat[itrain, ]
test <- bodyfat[-itrain, ]
fit <- lm(bodyfat ~ abdomen + wrist, data = train)
pred <- predict(fit, newdata = test)
obs <- test$bodyfat
pred.plot(pred, obs)
accuracy(pred, obs)
#> me rmse mae mpe mape r.squared
#> 1.589182743 4.399764982 3.688874689 0.002059976 21.308275784 0.700759788