R/mix_simulate.R
mix_simulate.Rd
Wrapper function that runs mix_predict()
on simulated data from generate_x()
.
Data is generated for each species based on their respective ranges of the
predictor variable, which can be extrapolated to values defined by the user.
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_simulate(
data,
modelselect,
level = 0.95,
extrapolate = NULL,
length.out = 100,
stat = "median",
n.sims = 1000,
response = "height",
predictor = "diameter",
species = "species",
...
)
Dataframe used to generate data and their predictions the using mixed-effects model. Columns should contain 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
.
Numeric vector of 2 elements (e.g. c(0,4)
), representing
the upper and lower bounds of extrapolation. Defaults to NULL
for no
extrapolation.
Number of new predictor values to generate for each species. Defaults to 100. Set a higher value for greater resolution at the cost of computational time.
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 response variable in data
. Defaults to
height
.
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()
A dataframe with columns:
Name of tree species.
Variable used to make predictions.
Predicted value.
Lower bound of the prediction interval, based on the input argument level
.
Upper bound of the prediction interval, based on the input argument level
.
Indicates whether the predictions are based on extrapolated values. Either 'High', 'Low', or 'No' (not extrapolated).
generate_x()
to generate new values for each species in a dataset.
mix_predict()
to make predictions for all species in a dataset using linear mixed-effects model.
merTools::predictInterval()
to make predictions from models fit with the lme4
package.
Other mixed-effects model functions:
mix_modelselect()
,
mix_predict()
data(urbantrees)
if (FALSE) {
model <- mix_modelselect(urbantrees)
results <- mix_simulate(data = urbantrees, modelselect = model)
head(results)
}