Skip to content

Commit

Permalink
background-formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidhuharp97 committed Jul 24, 2024
1 parent ef75ef6 commit 4aa7800
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions chapters/background.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Mixed-effects models are called “mixed” because they simultaneously model fixed and random effects. Fixed effects (e.g. treatments) represent population-level (i.e., average) effects that should persist across experiments. Fixed effects are similar to the parameters found in “traditional” regression techniques like ordinary least squares. Random effects are discrete units sampled from some population (e.g. plots, pariticipants), they are inherently categorical (Winter, 2019).


#### Model

Recall simple linear regression with intercept (β~0~) and slope (β~1~) effect for subject *i*. The (β~0~) and (β~1~) are chosen in a way so that the residual sum of squares is as small as possible.

$$ Y = \beta_0 + \beta_1(X) + 𝜺$$
Expand All @@ -14,25 +17,25 @@ $$ Y = \beta_0 + b_i + \beta_1(X) + 𝜺$$

In this model, predictions would vary depending on each subject’s random intercept term, but slopes would be the same:

![Example mixed model with random intercepts but identical slopes.](/img/random_intercept_same_slope.png){width="840"}
![Example mixed model with random intercepts but identical slopes.](/img/random_intercept_same_slope.png){width="501"}

In second case, we can have a fixed intercept and a random slope. The model will be:

$$ Y = \beta_0 + (\beta_1 + b_i)(X) + 𝜺$$

In this model, the *bi* is a random effect for subject *i* applied to the slope. Predictions would vary with random slope term, but the intercept will be the same:

![Mixed model with random slopes but identical intercepts.](/img/fixed_intercept_random_slope.png){width="840"}
![Mixed model with random slopes but identical intercepts.](/img/fixed_intercept_random_slope.png){width="501"}

Third case would be the mixed model with random slope and intercept:

$$ Y = (\beta_0 + ai) + (\beta_1 + b_i)(X) + 𝜺$$

In this model, a*i* and b*i* are random effects for subject *i* applied to the intercept and slope, respectively. Predictions would vary depending on each subject’s slope and intercept terms:

![Mixed Model with random intercept and slope](/img/random_intercept_and_slope.png)
![Mixed Model with random intercept and slope](/img/random_intercept_and_slope.png){width="526"}

### Random-effect syntax
#### Random-effect syntax

- (1\| group): Random intercept with fixed mean.

Expand Down

0 comments on commit 4aa7800

Please sign in to comment.