7
$\begingroup$

Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?


I have a three-level model representing experimental time series data. I am testing if participants' ratings on three variables (A, B, and C) predict their time series values. Values are nested within stimulus number, which is nested within the participant.

  • [time point] (t): each time series trial consists of 120 data points; i.e., there are 120 data points per stimulus_num
  • stimulus_num (k): each experimental session consisted of 36 trials; i.e., there are 36 stimuli per participant
  • ID (i): each unique participant; 77 participants total
  • A, B, and C: three ratings made by the participant before s/he completed each trial
  • value: the time series value provided by participant i at time point t for stimulus k

To clarify, each participant completed 36 trials. In each of the 36 trials, there are 120 data points (value) collected. Therefore, each participant should have 4,320 data points.

Here is the model:

lmer(value ~ A + B + C + (1|ID/stimulus_num), data = data)

For the equations at each level, I have:

Level 1: $$ Y _{ikt} = \beta _{0ik} + \beta _{1ik} A_{ikt} + \beta _{2ik} B_{ikt} + \beta _{3ik} C_{ikt} + e _{ikt} $$

Level 2: $$ \beta _{0ik} = \gamma _{00i} + u _{0ik} $$ $$ \beta _{1ik} = \gamma _{10i} + u _{1ik} $$ $$ \beta _{2ik} = \gamma _{20i} + u _{2ik} $$ $$ \beta _{3ik} = \gamma _{30i} + u _{3ik} $$

Level 3: $$ \gamma _{00i} = \pi _{000} + r _{00i} $$ $$ \gamma _{10i} = \pi _{100} + r _{10i} $$ $$ \gamma _{20i} = \pi _{200} + r _{20i} $$ $$ \gamma _{30i} = \pi _{300} + r _{30i} $$


My interpretation of the terms in the model:

At level 1, the outcome $Y _{ikt}$ represents person i's time series value for stimulus k at time point t. This outcome was modeled as a function of a random intercept $\beta _{0ik}$ and the Level 1 fixed effects of A, B, and C ($\beta _{1ik}$, $\beta _{2ik}$, and $\beta _{3ik}$).

At Level 2, $\gamma _{00i}$ is the random intercept, while $\gamma _{10i}$, $\gamma _{20i}$, and $\gamma _{30i}$ represent the time series value for stimulus k at time point t as a function of A, B, and C respectively. The effects $u _{nik}$ represent the variation each individual stimulus has relative to the grand mean for that equation.

At Level 3, $\pi _{000}$ is the random intercept, while $\pi _{100}$, $\pi _{200}$, and $\pi _{300}$ represent the time series value for stimulus k at time point t and for participant i as a function of A, B, and C respectively. Effects $r _{n0i}$ represent the variation each individual person has relative to the grand mean for that equation.

I am not sure that I have a) written the Level 1-3 formulas correctly to reflect how I built the model, and b) explained the coefficients in the model correctly, especially for levels 2 and 3. Also, have I reflected the random intercepts on "stimulus number" and "participant" correctly?


Edit: adding output of summary(data), str(data) and head(data, 10) as requested.

    > summary(data)
           ID             value             stimulus_num        A                B                C      
     1188   :  4248   Min.   :-10.0000   Min.   : 1.00   Min.   :  0.00   Min.   :  0.00   Min.   :  0.00  
     4431   :  4248   1st Qu.: -3.0000   1st Qu.:10.00   1st Qu.: 30.00   1st Qu.: 10.00   1st Qu.: 25.00  
     f6498  :  4248   Median :  0.0000   Median :18.00   Median : 50.00   Median : 30.00   Median : 50.00  
     f7876  :  4248   Mean   : -0.1655   Mean   :18.49   Mean   : 47.81   Mean   : 35.14   Mean   : 47.36  
     f8100  :  4248   3rd Qu.:  2.0000   3rd Qu.:27.00   3rd Qu.: 60.00   3rd Qu.: 58.00   3rd Qu.: 65.00  
     f8102  :  4248   Max.   : 10.0000   Max.   :36.00   Max.   :100.00   Max.   :100.00   Max.   :100.00  
     (Other):292522 
     > str(data)
    'data.frame':   318010 obs. of  6 variables:
     $ ID          : Factor w/ 77 levels "1188","4431",..: 1 1 1 1 1 1 1 1 1 1 ...
     $ value       : int  -2 -1 -3 -1 -1 0 -1 -2 -1 -1 ...
     $ stimulus_num: int  1 1 1 1 1 1 1 1 1 1 ...
     $ A           : int  25 25 25 25 25 25 25 25 25 25 ...
     $ B           : int  75 75 75 75 75 75 75 75 75 75 ...
     $ C           : int  75 75 75 75 75 75 75 75 75 75 ...
    > head(data, 10)
         ID value stimulus_num  A       B       C
    1  1188    -2        1      25      75      75
    2  1188    -1        1      25      75      75
    3  1188    -3        1      25      75      75
    4  1188    -1        1      25      75      75
    5  1188    -1        1      25      75      75
    6  1188     0        1      25      75      75
    7  1188    -1        1      25      75      75
    8  1188    -2        1      25      75      75
    9  1188    -1        1      25      75      75
    10 1188    -1        1      25      75      75

$\endgroup$
4
  • $\begingroup$ Can you give a bit more detail about the experiment. Are there are 120 measurements/values for each stimulus and 36 stimuli for each participant ? How many participants ? Also please edit your question to include the output of summary(yourdata), str(yourdata) and head(yourdata, 10) $\endgroup$ Jun 26, 2020 at 4:51
  • $\begingroup$ @RobertLong Thank you for your comment. I have added the requested information! $\endgroup$
    – Betsy S.
    Jun 26, 2020 at 13:05
  • $\begingroup$ Thanks, that clarifies a few things. Why is time_point not in the model ? Do you expect some trend over time or is it simply repeated for better accuracy ? $\endgroup$ Jun 26, 2020 at 15:40
  • $\begingroup$ @RobertLong - yes, it is repeated for better accuracy (we don't expect some trend over time necessarily). We test time dynamics in other models, but here we are interested in mean level responses for "value" predicted by variables A, B, and C. $\endgroup$
    – Betsy S.
    Jun 26, 2020 at 16:16

1 Answer 1

5
$\begingroup$

Question: Have I written formulas that convey the correct mathematical representation for my three-level model? Is my written interpretation of the coefficients in the equations correct?

Unfortunately, no. The model you are fitting:

lmer(value ~ A + B + C + (1|ID/stimulus_num), data = data)

has the following features:

  • A global intercept (fixed effect)
  • Fixed effects for A, B and C, which vary at the participant level, $i$, so these will generate 3 fixed effects estimates
  • Random intercepts for ID and the ID:stimulus_num interaction, which means that stimulus_num is nested in ID, so this will generate 2 random intercepts estimates

Therefore we expect the model to produce 7 estimates (4 fixed effects, 2 random interecps and 1 unit-level residual). When writing out the mathematics of a specific model it is always good to know how many, and what kind of, estimates are expected

It looks like your equations are on the right track, but note that, for level 2 and 3 you only need the first equation - the others would be needed only if you were fitting random slopes. So the level 2 and 3 equations are only random intercepts. Also, your index notation is not quite right because, with the usual convention, the first index should refer to the lowest level, not the highest. Perhaps you were confused because commonly $i$,$j$ and $k$ refer to levels 1, 2 and 3, whereas you are using $t$,$k$ and $i$

Also, you have the fixed effects indexed by $ikt$ which, apart from being in the wrong order is incorect because they only vary at the the individual ($i$) level.

Thus to write the mutilevel model equations we will adopt standard notation (for instance in the book by Snijders and Bosker), using subscripts ordered from level 1 to level 3. For example $Y_{tki}$ refers to time point $t$ in stimulus $k$ in participant $i$.

Thus, for level 1 we can write:

$$ Y_{tki} = \beta_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki} $$

where $\beta_{0ki}$ is the intercept in level-2 unit (stimulus) $k$ within level-3 unit (participant) $i$. For this we have the level 2 model:

$$ \beta_{0ki} = \gamma_{00i} + u_{0ki} $$

where $\gamma_{00i}$ is the average intercept in level-3 unit (participant) $i$. For this average intercept we have the level-3 model:

$$ \gamma_{00i} = \pi_{000} + r_{00i} $$

Putting it all together we have:

$$ Y_{tki} = \pi_{000} + r_{00i} + u_{0ki} + \beta_{1}A_{i} + \beta_{2}B_{i} + \beta_{3}C_{i} + e_{tki} $$

and this would result in 7 estimates from the model, as expected - 4 fixed effects: $\pi_{000}$, $\beta_1$, $\beta_2$, and $\beta_3$; and 3 random effects: $r_{00i}$, $u_{0ki}$, and $e_{tki}$

Regarding interpretation:

$\pi_{000}$ is the global intercept: it is the mean of the time series' when the fixed effects, A, B and C are all at zero.

$\beta_1$, represent the expected difference in the time series' for a 1 unit change in A, with the other fixed effects held constant. Sinmilarly for $\beta_2$ and $\beta_3$

$r_{00i}$ is the random intercept for individuals and the software will estimate a variance for this

$u_{0ki}$ is the random intercept for stimulus and the software will estimate a variance for this

$e_{tki}$ is the unit-level (time series level) residual and the software will estimate a variance for this.

$\endgroup$
4
  • 1
    $\begingroup$ Thank you so much for this detailed explanation. I am very grateful for the generosity with which you share your knowledge. I notice you don't include 𝛽0𝑘𝑖 and 𝛾00𝑖 in the composite equation or describe them. I understand that we don't include these terms in the composite equation because they are fully explained by terms 𝜋000, 𝑟00𝑖, and 𝑢0𝑘𝑖. If I were to describe terms 𝛽0𝑘𝑖 and 𝛾00𝑖 in my writing, what would I call them? Are they (non-global) fixed intercepts? Fixed intercepts for levels 1 and 2 respectively? $\endgroup$
    – Betsy S.
    Jun 29, 2020 at 14:48
  • 1
    $\begingroup$ One more question: variables A, B, and C, are rated before the time series data is collected. Each participant only has a single value on variable A for each stimulus (same for B and C). For this reason, variables A, B, and C don't differ as a function of the time series value. Is the subscript (t) still appropriate on A, B, and C? $\endgroup$
    – Betsy S.
    Jun 29, 2020 at 14:53
  • 1
    $\begingroup$ @E.Wade you're welcome. These are good follow-up questions. First, I have now edited the answer to cover those variables and the explanation/notation which is that used in the book by Snijders and Bosker. Second, unfortunatey I made a mistake, A, B and C should be subscripted by $i$ not $t$ - thanks for noticing that, I have fixed it now ! $\endgroup$ Jun 29, 2020 at 16:22
  • 1
    $\begingroup$ Many thanks, @RobertLong. I was wondering if you had done that because effects can only vary at the unit of the level on which they are included. Your correction helps clarify for me that that is not the case. $\endgroup$
    – Betsy S.
    Jun 29, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.