View source: R/nested_model_info.R
get_nested_model_info | R Documentation |
Constructs or extracts a nested model (fit0
) from a full model (fit1
)
using flexible input: a model object, formula, character string, or matrix.
This function is useful for preparing models for comparison, e.g., via likelihood ratio test.
get_nested_model_info(fit1, fit0)
fit1 |
A fitted model object (e.g., from |
fit0 |
A nested model specification: a model object, a formula (e.g., |
A list with:
Formula for fit1
.
Formula for resolved fit0
.
The full model fit1
.
The nested model fit0
.
Restriction matrix defining the nested model.
if (requireNamespace("lme4", quietly = TRUE)) {
library(lme4)
data(sleepstudy)
fit1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
fit0 <- lmer(Reaction ~ (Days | Subject), sleepstudy)
get_nested_model_info(fit1, fit0) # as model object
get_nested_model_info(fit1, ~ . - Days) # as formula
get_nested_model_info(fit1, "Days") # as string
## get_nested_model_info(fit1, c(0, 1)) # numeric (converted to matrix)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.