ss_modelfit_multi: Fit data to specified linear models across multiple species

View source: R/ss_modelfit.R

ss_modelfit_multiR Documentation

Fit data to specified linear models across multiple species

Description

Wrapper function that runs ss_modelfit() across multiple species. Data is fit to specified allometric equations for each species, as defined within ref_table. The full list of allometric equations that may be considered in ref_table can be found in ?eqns_info and data(eqns_info).

Usage

ss_modelfit_multi(
  data,
  ref_table,
  species = "species",
  modelcode = "modelcode",
  response = "height",
  predictor = "diameter"
)

Arguments

data

Dataframe that contains the variables of interest. Each row is a measurement for an individual tree of a particular species.

ref_table

Dataframe containing an allometric equation for each tree species, in the form of a model code. Each row is a unique species.

species

Column name of the species variable in both the dataframes data and ref_table. Defaults to species.

modelcode

Column name containing the model codes in ref_table. Refer to data(eqns_info) for more information on model codes.

response

Column name of the response variable in data. Defaults to height.

predictor

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

Value

A list of 2 elements:

ss_models

List of each species' resulting model object.

ss_models_info

Table showing each species' resulting model information.

ss_models_info

A dataframe with the following variables:

species

Name of tree species.

modelcode

Model code for the allometric equation used.

a, b, c, d, e

Parameter estimates.

response_geom_mean

Geometric mean of the response variable used in calculation of AICc (only for transformed models).

correctn_factor

Bias correction factor to use on model predictions (only for transformed models).

predictor_min, predictor_max

Range of the predictor variable within the data used to generate the model.

response_min, response_max

Range of the response variable within the data used to generate the model.

residual_SE

Residual standard error of the model.

mean_SE

Mean standard error of the model.

adj_R2

Adjusted R^2 of the model.

n

Sample size (no. of trees used to fit model).

See Also

ss_modelfit() to fit a specified model for one species.

ss_modelselect() to select a best-fit model for one species.

ss_modelselect_multi() to select best-fit models across multiple species.

Other single-species model functions: ss_modelfit(), ss_modelselect_multi(), ss_modelselect(), ss_predict(), ss_simulate()

Examples

# first select best-fit model for all species in data
data(urbantrees)
selected <- ss_modelselect_multi(urbantrees, species = 'species',
                                 response = 'height', predictor = 'diameter')

# use function
results <- ss_modelfit_multi(
  urbantrees, # any data with similar species (re-use same data in this case)
  ref_table = selected$ss_models_info,
  species = 'species', modelcode = 'modelcode',
  response = 'height', predictor = 'diameter'
)

results$ss_models[[1]] # model object for first species in list

results$ss_models_info # summary of fitted models


xp-song/allometree documentation built on March 28, 2022, 4:36 a.m.