Learn R Programming

webSDM (version 1.1-5)

coef.SDMfit: 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 SDMfit
coef(object, standardise = FALSE, level = 0.95, ...)

Value

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

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

Author

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

Run this code
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

Run the code above in your browser using DataLab