r_squared.Rd
This function is used to calculate the multiple and adjusted R squared values for a set of model estimates.
r_squared(estimates, data, response, x_vars, display = TRUE)
A data frame with 2 columns. The first column must hold the variable names and if there is an intercept, the intercept should also have a name in this column. The second column should hold the estimates
The data frame used in the model
A character equal to the name of the column in data
that holds the response variable
A character or vector of the explanatory variable names. Should also equal the column names
in data
that holds the explanatory variable data. The name of the intercept should NOT be included
in this vector.
Logical. If TRUE
, then the R Squared values are printed.
A data frame with 1 row and 2 columns. The columns hold the Multiple R Squared and the Adjusted R Squared, respectively.
if (FALSE) {
library(MuMIn)
library(AICcmodavg)
## lm.sr is an object returned from sr.LM()
dat <- lm.sr[['Data']][['Anolis.N']]
out <- AIC_avg(lm.sr[['Models']][['Anolis.N']],
data = dat,
response = 'Anolis.N',
x_vars = c(vars, 'sq_Area'),
groups = data.frame(Genus = 'Anolis',
Status = 'N'),
cum.weight = 0.95,
table = FALSE)
vars <- attr(lm.sr[['Models']][['Anolis.N']]$terms,'term.labels')
tmp <- r_squared(out[, c('Variable', 'Estimate')],
data = dat,
response = 'Anolis.N',
x_vars = vars,
display = FALSE)
}