Learn R Programming

weights (version 1.1.1)

coeffer: Extract model coefficients with standard errors and significance stars

Description

coeffer is a generic function to extract estimates, standard errors, p-values, and significance stars from a fitted model object. It supports a variety of common model types including linear, generalized linear, ordinal, mixed-effects, additive, penalized, and multinomial regression models.

Usage

coeffer(x, digits = 2, vertical = TRUE, approx.p = FALSE, s = "lambda.1se", ...)

Value

A list with the following components (or a list of such lists for multinom models):

  • rn — Coefficient names

  • est — Point estimates

  • ses — Standard errors

  • pval — P-values, where available (otherwise NA)

  • star — Significance stars based on p-values

  • cps — Cutpoint names for ordinal models (otherwise NULL)

Arguments

x

A fitted model object. Supported classes include lm, glm, polr, lmerMod, gam, glmnet, and multinom.

digits

Number of digits to retain in internal rounding (used for formatting).

vertical

Logical; included for compatibility, but not used by most methods.

approx.p

Logical; if TRUE, attempts to compute approximate p-values for models that do not provide them (e.g., lmerMod). Defaults to FALSE.

s

Sets s = "lambda.1se" or sets s to other value for glmnet models.

...

Additional arguments passed to methods.

Author

Josh Pasek

Details

For models that do not provide p-values (e.g., lmer, glmnet), approx.p = TRUE will attempt to calculate approximate p-values using standard normal approximations based on the ratio of estimate to standard error. This should be used with caution.

multinom models return a list of coefficient sets, one for each outcome level.

See Also

summary, onetable, pR2, polr, multinom, lmer, gam, glmnet

Examples

Run this code
data(mtcars)
mod1 <- lm(mpg ~ wt + hp, data = mtcars)
coeffer(mod1)

mod2 <- glm(am ~ wt + hp, data = mtcars, family = binomial)
coeffer(mod2)

library(MASS)
mod3 <- polr(Sat ~ Infl + Type + Cont, data = housing)
coeffer(mod3)

library(lme4)
mod4 <- lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy)
coeffer(mod4)
coeffer(mod4, approx.p = TRUE)

library(mgcv)
mod5 <- gam(mpg ~ s(wt) + hp, data = mtcars)
coeffer(mod5)

library(glmnet)
x <- model.matrix(mpg ~ wt + hp, data = mtcars)[, -1]
y <- mtcars$mpg
mod6 <- glmnet(x, y)
coeffer(mod6, s = mod6$lambda.min)

library(nnet)
mod7 <- multinom(vs ~ wt + hp, data = mtcars, trace = FALSE)
coeffer(mod7)

Run the code above in your browser using DataLab