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
summary(yourdata)
,str(yourdata)
andhead(yourdata, 10)
$\endgroup$time_point
not in the model ? Do you expect some trend over time or is it simply repeated for better accuracy ? $\endgroup$