Learn R Programming

parameters (version 0.5.0)

degrees_of_freedom: Degrees of Freedom (DoF)

Description

Estimate or extract degrees of freedom of models.

Usage

degrees_of_freedom(model, method = "analytical")

dof(model, method = "analytical")

Arguments

model

A statistical model.

method

Can be "analytical" (default, DoFs are estimated based on the model type), "fit", in which case they are directly taken from the model if available (for Bayesian models, the goal (looking for help to make it happen) would be to refit the model as a frequentist one before extracting the DoFs), "ml1" (see dof_ml1), "betwithin" (see dof_betwithin), "satterthwaite" (see dof_satterthwaite), "kenward" (see dof_kenward) or "any", which tries to extract DoF by any of those methods, whichever succeeds.

Examples

Run this code
# NOT RUN {
model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris)
dof(model)

model <- glm(vs ~ mpg * cyl, data = mtcars, family = "binomial")
dof(model)

if (require("lme4")) {
  model <- lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
  dof(model)
}
# }
# NOT RUN {
if (require("rstanarm")) {
  model <- stan_glm(
    Sepal.Length ~ Petal.Length * Species,
    data = iris,
    chains = 2,
    refresh = 0
  )
  dof(model)
}
# }

Run the code above in your browser using DataLab