This function is used to predict Y values from averaged estimates for specified X values.

avg_predict(
  estimates,
  new.data,
  x_vars,
  se = FALSE,
  data = NULL,
  response = NULL
)

Arguments

estimates

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

new.data

A data frame that holds the new data to predict from. Should have the same number of columns as length(x_vars)

x_vars

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.

data

The data frame used in the model

response

A character equal to the name of the column in data that holds the response variable

Value

A data frame with length(x_vars) + 1 columns and nrow(new.data) rows. The data frame has the new.data and the estimated values (in a column named 'Y.hat').

Examples

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')

preds <- avg_predict(out[, c('Variable', 'Estimate')],
                     new.data = dat,
                     x_vars = vars)

}