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.
efronRSquared(
model = NULL,
actual = NULL,
predicted = NULL,
residual = NULL,
statistic = "EfronRSquared",
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, 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 |
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 linear models
(lm
model objects), Efron's pseudo r-squared will be equal
to r-squared.
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 model
is not supplied,
two of the following need to 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(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.