Indexes of Absolute Prediction Error for Linear Models
abs.error.pred.RdComputes the mean and median of various absolute errors related to ordinary multiple regression models. The mean and median absolute errors correspond to the mean square due to regression, error, and total. The absolute errors computed are derived from \(\hat{Y} - \mbox{median($\hat{Y}$)}\), \(\hat{Y} - Y\), and \(Y - \mbox{median($Y$)}\). The function also computes ratios that correspond to \(R^2\) and \(1 - R^2\) (but these ratios do not add to 1.0); the \(R^2\) measure is the ratio of mean or median absolute \(\hat{Y} - \mbox{median($\hat{Y}$)}\) to the mean or median absolute \(Y - \mbox{median($Y$)}\). The \(1 - R^2\) or SSE/SST measure is the mean or median absolute \(\hat{Y} - Y\) divided by the mean or median absolute \(\hat{Y} - \mbox{median($Y$)}\).
Usage
abs.error.pred(fit, lp=NULL, y=NULL)
# S3 method for class 'abs.error.pred'
print(x, ...)Arguments
- fit
a fit object typically from
lmorolsthat contains a y vector (i.e., you should have specifiedy=TRUEto the fitting function) unless theyargument is given toabs.error.pred. If you do not specify thelpargument,fitmust containfitted.valuesorlinear.predictors. You must specifyfitor both oflpandy.- lp
a vector of predicted values (Y hat above) if
fitis not given- y
a vector of response variable values if
fit(withy=TRUEin effect) is not given- x
an object created by
abs.error.pred- ...
unused
Value
a list of class abs.error.pred (used by
print.abs.error.pred) containing two matrices:
differences and ratios.
Author
Frank Harrell
Department of Biostatistics
Vanderbilt University School of Medicine
fh@fharrell.com
See also
lm, ols, cor,
validate.ols
References
Schemper M (2003): Stat in Med 22:2299-2308.
Tian L, Cai T, Goetghebeur E, Wei LJ (2007): Biometrika 94:297-311.
Examples
set.seed(1) # so can regenerate results
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- exp(x1+x2+rnorm(100))
f <- lm(log(y) ~ x1 + poly(x2,3), y=TRUE)
abs.error.pred(lp=exp(fitted(f)), y=y)
#>
#> Mean/Median |Differences|
#>
#> Mean Median
#> |Yi hat - median(Y hat)| 1.983447 0.8651185
#> |Yi hat - Yi| 2.184563 0.5436367
#> |Yi - median(Y)| 2.976277 1.0091661
#>
#>
#> Ratios of Mean/Median |Differences|
#>
#> Mean Median
#> |Yi hat - median(Y hat)|/|Yi - median(Y)| 0.6664189 0.8572607
#> |Yi hat - Yi|/|Yi - median(Y)| 0.7339920 0.5386989
rm(x1,x2,y,f)