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).

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
#> 
#> Call:
#> lm(formula = y ~ x)
#> 
#> Coefficients:
#> (Intercept)            x  
#>       6.717        9.464  
#> 

results$ss_models_info # summary of fitted models
#>                    species modelcode         a           b          c        d
#> 1            Albizia saman    lin_w1  6.717431   9.4640964         NA       NA
#> 2            Hopea odorata  quart_w4 -1.149669 149.3178483 -1522.6122 7908.410
#> 3     Syzygium myrtifolium  quart_w2 -4.614100 158.5128488  -748.2492 1638.676
#> 4       Terminalia mantaly   expo_w1  1.241983   3.8600410         NA       NA
#> 5 Xanthostemon chrysanthus loglog_w1  2.947907   0.5916555         NA       NA
#>            e response_geom_mean correctn_factor predictor_min predictor_max
#> 1         NA          13.566083        1.000000    0.31194369     1.5278875
#> 2 -14225.442           5.390829        1.000000    0.03183099     0.2928451
#> 3  -1321.221           7.735643        1.000000    0.04138029     0.5665916
#> 4         NA           7.596013        1.000533    0.03501409     0.5602254
#> 5         NA           5.041605        1.000883    0.02864789     0.3533240
#>   response_min response_max residual_SE mean_SE adj_R2   n
#> 1            8           20      2.2050  4.7889 0.4276 133
#> 2            2           15     11.9430  2.6339 0.5460 483
#> 3            1           18      2.1674  2.2536 0.6662 353
#> 4            3           18      0.2493  0.0615 0.6702 197
#> 5            2           13      0.2123  0.0449 0.6137 418