| efronRSquared | R Documentation |
Produces Efron's pseudo r-squared from certain models, or vectors of residuals, predicted values, and actual values. Alternately produces minimum maximum accuracy, mean absolute percent error, root mean square error, or coefficient of variation. Alternately produces a fit statistic based on absolute deviations.
efronRSquared(
model = NULL,
actual = NULL,
predicted = NULL,
residual = NULL,
statistic = "EfronRSquared",
null.absolute.deviation = "mean",
rescale.adr = TRUE,
plotit = FALSE,
digits = 3,
...
)
model |
A model of the class lm, glm, nls, betareg, gls, lme, lmerMod, lmerModLmerTest, glmmTMB, rq, loess, gam, negbin, glmRob, rlm, rfit, or mblm. |
actual |
A vector of actual y values |
predicted |
A vector of predicted values |
residual |
A vector of residuals |
statistic |
The statistic to produce.
One of |
null.absolute.deviation |
For the |
rescale.adr |
For the |
plotit |
If |
digits |
The number of significant digits in the output. |
... |
Other arguments passed to |
Efron's pseudo r-squared is calculated as 1 minus the residual sum
of squares divided by the total sum of squares. For
(lm model objects), Efron's pseudo r-squared will be equal
to r-squared.
Absolute deviation pseudo r-squared is calculated as 1 minus the absolute deviations of predicted and observed values divided by the absolute deviation of observed values from their mean or median. By default, this value is re-scaled to be similar in magnitude to an r-squared value.
This function produces the same statistics as does the
accuracy function.
While the accuracy function extracts values from a model
object, this function allows for the manual entry
of residual, predicted, or actual values.
It is recommended that the user consults the accuracy
function
for further details on these statistics, such as if the reported
value is presented as a percentage or fraction.
If modelis not supplied,
two of the following need to be passed to the function:
actual, predicted, residual.
Note that, for some model objects, to extract residuals
and predicted values on the original scale,
a type="response"
option needs to be added to the call, e.g.
residuals(model.object, type="response").
A single statistic
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
https://rcompanion.org/handbook/F_16.html
accuracy,
nagelkerke
data(BrendonSmall)
BrendonSmall$Calories = as.numeric(BrendonSmall$Calories)
BrendonSmall$Calories2 = BrendonSmall$Calories ^ 2
model.1 = lm(Sodium ~ Calories + Calories2, data = BrendonSmall)
efronRSquared(model.1)
efronRSquared(model.1, statistic="MAPE")
efronRSquared(model.1, statistic="AbsoluteDeviationRSquared")
efronRSquared(actual=BrendonSmall$Sodium, residual=model.1$residuals)
efronRSquared(residual=model.1$residuals, predicted=model.1$fitted.values)
efronRSquared(actual=BrendonSmall$Sodium, predicted=model.1$fitted.values)
summary(model.1)$r.squared
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.