Extracting coefficients
We often want to know what values a model estimates as coefficients. Although the summary()
function provides the model outputs, we might also want to directly access model outputs.
The fixed-effects estimates can be called directly using the fixef()
function. The random-effects estimates can be called directly using the ranef()
function. We can also extract confidence intervals for the fixed-effects using the function confint()
.
The broom.mixed
package also contains tidy methods for extracting model results from lmer()
models, namely the tidy()
function. However, these results are more complex and less tidy than many tidy outputs due to the complexity of mixed-effect models.
A lmer
model has been fit for you and saved as out
.
This is a part of the course
“Hierarchical and Mixed Effects Models in R”
Exercise instructions
- Extract the fixed-effect coefficients using
fixef()
with the saved modelout
. - Extract the random-effect coefficients using the
ranef()
with the saved modelout
. - Estimate the 95% confidence intervals using the
confint()
function with the saved modelout
. - Use the
tidy()
without
andconf.int = TRUE
to repeat your previous three code calls with one tidy command.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Extract the fixed-effect coefficients
___
# Extract the random-effect coefficients
___
# Estimate the confidence intervals
___
# Use the tidy function
___