Instructor: Colin Grudzien

## Instructions: We will work through the following series of activities as a group and hold small group work and discussions in Zoom Breakout Rooms. Follow the instructions in each sub-section when the instructor assigns you to a breakout room. ## Activities: ```{r} require("faraway") ``` ### Activity 1: mixed effects of binary variables We will note in the following how we can construct a mixed effect model from a binary variable. The syntax in R is to use a `*` symbol instead of a `+` to introduce a mixed effect that can change the slope of the trend. This refers mathematically to the following idea in a simple regression model: Let $Z$ be the binary predictor that takes the values as follows: $$\begin{align} Z = \begin{cases} 1 & \text{ category 1} \\ 0 & \text{ category 2} \end{cases} \end{align}$$ The variable $X$ will represent some standard, continuous scale predictor. The resulting equation for the mixed effect model is $$\begin{align} Y = \beta_0 + \beta_1 X + \beta_2 Z + \beta_3 Z * X + \epsilon \end{align}$$ #### Question 1: Using this the above formula, derive how the mixed effect model changes the slope and intercept simultaneously when we shift between the two categories. #### Question 2: Construct the standard multiple regression model in which `gamble` is the response for all other variables as predictors in the `teengamb` data. Then construct the mixed effect model with `sex * (status + income + verbal)`. Examining the model summaries, what do you think about the mixed effects? Can you construct a reduced size, mixed effect model that gets at the most important aspects? Note, you should not remove the binary variable if there are significant mixed effects that depend on it. #### Question 3: Using the final model in the last question, produce an F test to determine if we favor a mixed effect model versus the simple encoding of the binary adjustment to the intercept. ### Activity 2 #### Question 1: Using the same mixed effect technique as in the last activity, try to systematically construct a mixed effect model in terms of `log(wage) ~ race * (educ + exper)`. What do you notice? #### Question 2: Using an F test with the mixed effect model in `log(wage) ~ race * (educ + exper)`, what do you conclude about using the mixed effect here?