Get startedGet started for free

Displaying chlamydia results

In the previous exercise, you fit a GLMER to the Illinois chlamydia data. During this exercise, we will go over some methods for displaying the results. You could use these methods to get summaries of the model for a client or document you are writing describing your results. However, I encourage you to learn how to manipulate and explore model outputs on your own to create your own methods for displaying results. Developing your own unique methods can help you stand out as a data scientist!

Here is what you will do:

  1. Examine the model estimates.
  2. Plot the data with and fit a glm to each age class. Although not exactly the same as the glmer() outputs, this approximation helps to display the results in a visually easy to understand method.

This exercise is part of the course

Hierarchical and Mixed Effects Models in R

View Course

Exercise instructions

  • Extract out the fixed-effect estimates from model_out using fixef().
  • Extract out the random-effect estimates from model_out using ranef().
  • Run the code to plot the data using ggplot2 methods.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Extract out fixed effects
___
# Extract out random effects 
___

# Run code to see one method for plotting the data
ggplot(data = il_data_2, 
       aes(x = year, y = count, group = county)) +
    geom_line() +
    facet_grid(age ~ . ) +
    stat_smooth(method = "glm",
                method.args = list(family = "poisson"), 
                se = FALSE,
                alpha = 0.5) +
    theme_minimal()
Edit and Run Code