coeffer {weights} | R Documentation |
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", ...)
Arguments
x |
A fitted model object. Supported classes include |
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 |
s |
Sets |
... |
Additional arguments passed to methods. |
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.
Value
A list with the following components (or a list of such lists for multinom
models):
rn
— Coefficient namesest
— Point estimatesses
— Standard errorspval
— P-values, where available (otherwiseNA
)star
— Significance stars based on p-valuescps
— Cutpoint names for ordinal models (otherwiseNULL
)
Author(s)
Josh Pasek
See Also
summary
, onetable
, pR2
, polr
, multinom
, lmer
, gam
, glmnet
Examples
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)