R/mix_predict.R
mix_predict.RdMake 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",
...
)Dataframe with columns containing the species and variables of interest. Each row is a measurement for an individual tree.
Output from the mix_modelselect() function.
Level of confidence for the prediction interval. Defaults to
0.95.
Specify whether the "median" or "mean" of simulated intervals are used.
Number of bootstrapped simulations to generate the prediction intervals. Defaults to 1000.
Column name of the predictor variable in data. Defaults to
diameter.
Column name of the species variable in data. Defaults to species.
Additional arguments passed to merTools::predictInterval()
Dataframe of input data with columns appended:
Predicted value for the response variable.
Lower bound of the prediction interval, based on the input argument level.
Upper bound of the prediction interval, based on the input argument level.
merTools::predictInterval() to make predictions from models fit with the lme4 package.
Other mixed-effects model functions:
mix_modelselect(),
mix_simulate()
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)
}