coef.SDMfit: Gets regression coefficients from a local model, i.e. a...

View source: R/coef.SDMfit.R

coef.SDMfitR Documentation

Gets regression coefficients from a local model, i.e. a SDMfit object.

Description

Gets regression coefficients (eventually standardised) of a local model, i.e. a SDMfit object. p-values or credible intervals are returned when available.

Usage

## S3 method for class 'SDMfit'
coef(object, standardise = FALSE, level = 0.95, ...)

Arguments

object

A SDMfit object, typically obtained with trophicSDM() and available in the field $model of a trophicSDMfit object

standardise

Whether to standardise regression coefficients. Default to FALSE. If TRUE, coefficients are standardised using the latent variable standardisation (see Grace et al. 2018) for more details.

level

The confidence level of credible intervals, only available for stan_glm method. Default to 0.95.

...

additional arguments

Value

A table containing the inferred coefficients (with credible intervals or p-values when available).

Author(s)

Giovanni Poggiato

References

Grace, J. B., Johnson, D. J., Lefcheck, J. S., and Byrnes, J. E. K.. 2018. Quantifying relative importance: computing standardized effects in models with binary outcomes. Ecosphere 9(6):e02283.

Examples

data(Y, X, G)
# define abiotic part of the model
env.formula = "~ X_1 + X_2"
# Run the model with bottom-up control using stan_glm as fitting method and no penalisation
m = trophicSDM(Y,X,G, env.formula, iter = 100,
               family = binomial(link = "logit"), penal = NULL, 
               mode = "prey", method = "stan_glm")
# unstandardised regression coefficients
coef(m$model$Y5)
#standardised regression coefficients with 90% credible intervals
coef(m$model$Y5, standardised = TRUE, level = 0.9)
# Run the same model using glm as fitting method
# (set iter = 1000 to obtain reliable results)
m = trophicSDM(Y,X,G, env.formula, 
               family = binomial(link = "logit"), penal = NULL, 
               mode = "prey", method = "glm")
# Now we have p-values instead of credible intervals
coef(m$model$Y5)

# Notice that unstandardised coefficients are always accessible
# in the fitted model:
m$model$Y5$coef

webSDM documentation built on June 24, 2024, 5:13 p.m.