fit_models: fit_models

Description Usage Arguments Value Examples

Description

fits several ecological models to test the effect of environmental variables on species traits across ecological gradients

Usage

1
2
fit_models(data, dep_var, ind_var, modelname, species = NULL,
  size_var = NULL, sites = NULL, rep_vectors, max_iter = 15000)

Arguments

data

The dataframe that contains the data

dep_var

numeric. The name of the column in 'data' that holds the trait for which to fit the predictive models

ind_var

numeric. The name of the column in 'data' that holds the numeric environmental variable (light, nutrients) that will act as main predictor of the response variable 'dep_var'

modelname

name of the object that contains the scientific function to be fit. User must provide also a list containing the initial values of the parameters of the model, the highest and the lowest possible values for those parameters. The names of these lists must be exactly the same as 'modelname' followed by the suffixes '.par', '.par.hi' and 'par.lo', respectively.

species

factor. Name of the species for which the model is gonna be fitted. If 'species = NULL' then the model is fit for all the dataframe together.

size_var

numeric. Name of the column in 'data' that contains the size of plants. If 'size = NULL' no effect of size is included in the model fitted.

sites

factor. Name of the column in 'data' that contains the name of the different sites along the gradient. This can be different elevations, different latitude, or different climate, for example. If 'sites = NULL' the function will fit one model for for all sites pooled together. Otherwise, the parameters of the model indicated in 'rep_vectors' will be allowed to take a different value for each site.

rep_vectors

vector. In the parameter list (provided by the user), position of the parameters that will be allowed to vary across sites. If sites != NULL and rep_vectors = NULL, all parameters in the function will be allowed to vary across sites.

max_iter

maximum number of iterations allowed for the 'anneal' function. By default 'max_iter = 15000'.

Value

This function fit a user-given scientific function to assess the effect of an environmental variable ('ind_var') on a given plant trait ('dep_var') across an environmental gradient of a second variable ('sites'). The model uses the function ànneal'in the 'likelihood'package to fit the model, and returns a list containing: - the best estimates of the parameters in the function - the upper limits - the lower limits - LL - AICc - slope -R2 - k

(please see the documentation for the 'anneal'function in the 'likelihood' package for more info in the output of this function.

Examples

1
2
data(ecophysio)
rdpi(ecophysio,sp,SB, Piso)

ameztegui/gradients documentation built on Nov. 2, 2019, 1:46 p.m.