DIAGNOSTICS: Diagnostics of models

DIAGNOSTICSR Documentation

Diagnostics of models

Description

Diagnostics of model results, it compares estimated values y with observed values x.

Usage

 R2 (x, y, na.rm=FALSE)
 RMSE (x, y, na.rm=FALSE) 
 MAE (x, y, na.rm=FALSE)
 RMSEP (x, y, na.rm=FALSE)
 MAEP (x, y, na.rm=FALSE)

Arguments

x

observed values

y

estimated values

na.rm

logical. Should missing values be removed?

Details

If x_i are the observed values, y_i the estimated values, with i=1,...,n, and \bar{x} the sample mean of x_i, then:

R^2 = 1 - \frac{\sum_1^n (x_i-y_i)^2}{\sum_1^n x_i^2 - n \bar{x}^2}

RMSE = \sqrt{\frac{1}{n} \sum_1^n (x_i-y_i)^2}

MAE = \frac{1}{n} \sum_1^n |x_i-y_i|

RMSEP = \sqrt{\frac{1}{n} \sum_1^n ((x_i-y_i)/x_i)^2}

MAEP = \frac{1}{n} \sum_1^n |(x_i-y_i)/x_i|

See https://en.wikipedia.org/wiki/Coefficient_of_determination, https://en.wikipedia.org/wiki/Mean_squared_error and https://en.wikipedia.org/wiki/Mean_absolute_error for other details.

Value

R2 returns the coefficient of determination R^2 of a model.

RMSE returns the root mean squared error of a model.

MAE returns the mean absolute error of a model.

RMSE returns the percentual root mean squared error of a model.

MAE returns the percentual mean absolute error of a model.

Note

For information on the package and the Author, and for all the references, see nsRFA.

See Also

lm, summary.lm, predict.lm, REGRDIAGNOSTICS

Examples

data(hydroSIMN)

datregr <- parameters
regr0 <- lm(Dm ~ .,datregr); summary(regr0)
regr1 <- lm(Dm ~ Am + Hm + Ybar,datregr); summary(regr1)

obs <- parameters[,"Dm"]
est0 <- regr0$fitted.values
est1 <- regr1$fitted.values

R2(obs, est0)
R2(obs, est1)

RMSE(obs, est0)
RMSE(obs, est1)

MAE(obs, est0)
MAE(obs, est1)

RMSEP(obs, est0)
RMSEP(obs, est1)

MAEP(obs, est0)
MAEP(obs, est1)

nsRFA documentation built on Nov. 13, 2023, 5:07 p.m.