trending (version 0.0.2)

trending_model: Modeling interface

Description

These functions wrappers around various modelling tools to ensure a consistent input for trending functions. See details for available model interfaces.

Usage

glm_model(formula, family, ...)

glm_nb_model(formula, ...)

lm_model(formula, ...)

brms_model(formula, family, ...)

Arguments

formula

The formula of the model, with the response variable on the left of a tilde symbol, and predictors on the right hand-side; variable names used in the formula will need to be matched by columns in the data input to other functions.

family

The model family to be used for the response variable.

...

Further arguments passed underlying models: lm for lm_model(), glm for glm_model(), MASS::glm.nb() for glm_nb_model, brms::brm() for brms_model. Not used for print and format.

Value

A trending_model object (S3 class inheriting list), containing items which can be accessed by various accessors - see ?trending_model-accessors.

Details

The following interfaces are available:

  • lm_model: interface for linear models implemented in stats::lm().

  • glm_model: interface for generalised linear models (GLMs) implemented in stats::glm().

  • glm_nb_model: interface for negative binomial generalied linear models implemented in MASS::glm.nb.

  • brms_model: interface for Bayesian regression models implemented in brms::brm.

Examples

Run this code
# NOT RUN {
x = rnorm(100, mean = 0)
y = rpois(n = 100, lambda = exp(1.5 + 0.5*x))

poisson_model <- glm_model(y ~ x , family = "poisson")
negbin_model <- glm_nb_model(y ~ x)

# }

Run the code above in your browser using DataCamp Workspace