Make predictions across rows in a dataset that may contain multiple species. The mixed-effects model is used to predict values for the response variable, as well as it's prediction interval. Necessary bias-corrections are made if the mixed-effects model has a transformed response variable.

mix_predict(
  data,
  modelselect,
  level = 0.95,
  stat = "median",
  n.sims = 1000,
  predictor = "diameter",
  species = "species",
  ...
)

Arguments

data

Dataframe with columns containing the species and variables of interest. Each row is a measurement for an individual tree.

modelselect

Output from the mix_modelselect() function.

level

Level of confidence for the prediction interval. Defaults to 0.95.

stat

Specify whether the "median" or "mean" of simulated intervals are used.

n.sims

Number of bootstrapped simulations to generate the prediction intervals. Defaults to 1000.

predictor

Column name of the predictor variable in data. Defaults to diameter.

species

Column name of the species variable in data. Defaults to species.

...

Additional arguments passed to merTools::predictInterval()

Value

Dataframe of input data with columns appended:

fit

Predicted value for the response variable.

lwr

Lower bound of the prediction interval, based on the input argument level.

upr

Upper bound of the prediction interval, based on the input argument level.

See also

merTools::predictInterval() to make predictions from models fit with the lme4 package.

Other mixed-effects model functions: mix_modelselect(), mix_simulate()

Examples

data(urbantrees)

if (FALSE) {
model <- mix_modelselect(urbantrees)

Alb_sam <- urbantrees[urbantrees$species == 'Albizia saman', ]  # use one species as an example
results <- mix_predict(data = Alb_sam, modelselect = model,
                       predictor = "diameter") # make predictions for measured values

head(results)
}