R/ss_simulate.R
ss_simulate.Rd
Wrapper function that runs ss_predict()
on simulated data. Data is simulated
for each species based on the range of the predictor variable used to fit the
model, which can be extrapolated to values defined by the user. The
corresponding model object in models
will be used to make predictions on the
simulated data. The user may choose to run this function on one or multiple
species, using the argument select_sp
.
ss_simulate(
ref_table,
models,
select_sp = NULL,
level = 0.95,
length.out = 100,
extrapolate = NULL,
species = "species",
predictor_min = "predictor_min",
predictor_max = "predictor_max",
response_min = "response_min",
response_max = "response_max",
cf = "correctn_factor",
geom_mean = "response_geom_mean"
)
Dataframe containing model information. It should include
columns for species
, predictor_min
, predictor_max
, cf
, and
geom_mean
.
A named list of each species' linear regression models.
names(models)
should correspond to species names in ref_table
.
Character vector of species names, if you want to run this
function only for selected species in ref_table
. Defaults to NULL
, to
run function across all species.
Level of confidence for the prediction interval. Defaults to
0.95
.
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.
Numeric vector of 2 elements (e.g. c(0,4)
), representing
the upper and lower bounds of extrapolation. Defaults to NULL
for no
extrapolation.
Column name in ref_table
for the name of species. Defaults to
species
.
Column name in ref_table
for minimum value of the
predictor variable used to fit the model. Defaults to predictor_min
.
Column name in ref_table
for maximum value of the
predictor variable used to fit the model. Defaults to predictor_max
.
Column name in ref_table
for minimum value of the
response variable used to fit the model. Defaults to response_min
.
Column name in ref_table
for maximum value of the
response variable used to fit the model. Defaults to response_max
.
Column name in ref_table
for the bias correction factor. Defaults
to correctn_factor
.
Column name in ref_table
for the geometric mean of response
variable that was used in to fit the models
. Defaults to
response_geom_mean
.
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).
The model associated with each species is used to predict values for the response variable, as well as it's prediction interval. Necessary bias-corrections are made for species with models that have a transformed response variable.
ss_predict()
to make predictions for all species in a dataset using
single-species linear models.
Other single-species model functions:
ss_modelfit_multi()
,
ss_modelfit()
,
ss_modelselect_multi()
,
ss_modelselect()
,
ss_predict()
# first select best-fit model for all species in data
data(urbantrees)
results <- ss_modelselect_multi(urbantrees, species = 'species',
response = 'height', predictor = 'diameter')
if (FALSE) {
# simulate for all species
ss_simulate(ref_table = results$ss_models_info,
models = results$ss_models)
# simulate for selected species
ss_simulate(ref_table = results$ss_models_info,
models = results$ss_models,
selected_spp = 'Albizia saman')
# simulate with extrapolated values
ss_simulate(ref_table = results$ss_models_info,
models = results$ss_models,
extrapolate = c(0,3))
}