1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

The Random Intercept Model

The previous model assumes independence of the repeated measures of weight, and this assumption is highly unlikely. So, now we will move on to consider both some more appropriate graphics and appropriate models.

To begin the more formal analysis of the rat growth data, we will first fit the random intercept model for the same two explanatory variables: Time and Group. Fitting a random intercept model allows the linear regression fit for each rat to differ in intercept from other rats.

We will use the lme4 package which offers efficient tools for fitting linear and generalized linear mixed-effects models. The first argument is the formula object describing both the fixed-effects and random effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. Note the random-effects terms distinguished by vertical bars (|).

Instructions

100 XP
  • Access the lme4 package
  • Fit the random intercept model with the rat ID as the random effect
  • Print out the summary of the model
  • Pay attention to variability (standard deviation) of the rat ID