Learn R Programming

weights (version 1.1.1)

findn: Summarize key model information including sample size and fit statistics

Description

findn is a generic function that extracts useful summary information from a model object. It supports linear models (lm), generalized linear models (glm), ordinal regression models from polr, mixed-effects models from lmer, generalized additive models from gam, and multinomial models from multinom.

Usage

findn(x, ...)

Value

A named list with the following components, where available:

  • type — A character string describing the model type

  • n — The number of observations used in the model

  • r.squared — R-squared (for OLS and GAM models)

  • adj.r.squared — Adjusted R-squared (for OLS models)

  • mcfadden — McFadden's pseudo-R² (for GLMs and polr, if pscl is installed)

  • aic — AIC value for the model

The object is assigned class "findn" with a custom print method for display.

Arguments

x

A fitted model object of class lm, glm, polr, lmerMod, glmerMod, gam, or multinom.

...

Additional arguments passed to methods (currently unused).

Author

Josh Pasek

See Also

Examples

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

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

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

library(lme4)
mod4 <- lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy)
findn(mod4)

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

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

Run the code above in your browser using DataLab