Skip to contents

Estimate or extract residual or model-based degrees of freedom from regression models.

Usage

get_df(x, ...)

# S3 method for default
get_df(x, type = "residual", verbose = TRUE, ...)

Arguments

x

A statistical model.

...

Currently not used.

type

Can be "residual", "model" or "analytical". "residual" tries to extract residual degrees of freedoms. If residual degrees of freedom could not be extracted, returns analytical degrees of freedom, i.e. n-k (number of observations minus number of parameters). "model" returns model-based degrees of freedom, i.e. the number of (estimated) parameters.

verbose

Toggle warnings.

Examples

model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris)
get_df(model) # same as df.residual(model)
#> [1] 144
get_df(model, type = "model") # same as attr(logLik(model), "df")
#> [1] 7