# two-level model with level-1 and level-2 variable with random intercept and random slope
fit1 <- lme_model(
data = popular,
response_variable = popular,
random_effect_factors = c(extrav, sex),
non_random_effect_factors = texp,
id = class
)
# added two-way interaction factor
fit2 <- lme_model(
data = popular,
response_variable = popular,
random_effect_factors = c(extrav, sex),
non_random_effect_factors = texp,
two_way_interaction_factor = c(extrav, texp),
id = class
)
# pass a explicit lme model (I don't why you want to do that, but you can)
lme_fit <- lme_model(
model = "popular ~ extrav*texp + (1 + extrav | class)",
data = popular
)
Run the code above in your browser using DataLab