get_nested_model_info {pbkrtest} | R Documentation |
Resolve Nested Model Representation
Description
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.
Usage
get_nested_model_info(fit1, fit0)
Arguments
fit1 |
A fitted model object (e.g., from |
fit0 |
A nested model specification: a model object, a formula (e.g., |
Value
A list with:
- formula_large
Formula for
fit1
.- formula_small
Formula for resolved
fit0
.- large_model
The full model
fit1
.- small_model
The nested model
fit0
.- L
Restriction matrix defining the nested model.
Examples
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)
}
[Package pbkrtest version 0.5.5 Index]