Cross Validated Asked by E. Wade on January 3, 2022

**Question:** Have I correctly translated my lmer models into formulas depicting each individual level, as well as the composite formula? Specific questions about my work below.

**Information about my models and the data**

I have two two-level models representing experimental time series data. One model includes two-way interactions and the other model includes three-way interactions (the latter are terms of greatest interest). I am testing if participants’ previous values in the time series (the lagged variable) predict their current time series value, depending on the valence of the stimulus (positive, negative, ambiguous), a personality trait of interest, and the interactions between these. Values are nested within trial, which are nested within the participant.

**time point**(*t*): each time series trial consists of 120 data points, and each participant completed 36 trials. There are 120 data points per trial.**[stimulus_num]**(*k*): each experimental session consisted of 36 trials; i.e., there are 36 stimuli per participant. This part of the structure is not included in my model because it is somewhat redundant with the Stimulus Valence variables and to reduce the number of levels/terms in the model. However, I am including it here to fully explain the experimental structure.**ID**(*i*): each unique participant; 77 participants total**[Stimulus Valence]**each of the 36 time series trials falls into one of six different stimulus valence categories: major positive, minor positive, ambiguous, major positive, minor positive, and neutral. We recoded these categories to reduce the number of terms in the model. The original variable is therefore not in the model.**Stimulus Positivity:**if stimulus valence is major positive, this variable was coded as a 2. If stimulus valence is minor positive, this variable was coded as a 1. For all other stimulus valence categories, this variable was coded as 0. Then the variable was centered.**Stimulus Negativity**and**Stimulus Ambiguity:**same process as Stimulus Positivity above, but Stimulus Ambiguity only has one level and therefore was not centered.**value:**the time series value provided by participant*i*at time point*t*for stimulus*k***lagged_value:**the time series value provided by participant*i*at time point*t-10*for stimulus*k***Trait:**a self-reported personality trait provided by participant*i*prior to providing time series data (centered)

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 are some basic attributes of the data:

```
> summary(data)
ID value lagged_value Ambiguous_Valence Negative_Valence
9999 : 3528 Min. :-10.00000 Min. :-12.072000 Min. :0.0000 Min. :-0.5
4431 : 3528 1st Qu.: -3.00000 1st Qu.: -2.360544 1st Qu.:0.0000 1st Qu.:-0.5
f6498 : 3528 Median : 0.00000 Median : -0.005669 Median :0.0000 Median :-0.5
f7876 : 3528 Mean : -0.09446 Mean : 0.000000 Mean :0.1667 Mean : 0.0
f8100 : 3528 3rd Qu.: 3.00000 3rd Qu.: 2.139739 3rd Qu.:0.0000 3rd Qu.: 0.5
f8102 : 3528 Max. : 10.00000 Max. : 13.139740 Max. :1.0000 Max. : 1.5
(Other):211680
Positive_Valence Trait
Min. :-0.5 Min. :-9.79126
1st Qu.:-0.5 1st Qu.:-3.26158
Median :-0.5 Median : 1.32634
Mean : 0.0 Mean : 0.01372
3rd Qu.: 0.5 3rd Qu.: 3.43316
Max. : 1.5 Max. : 6.98598
```

```
> str(data)
'data.frame': 232848 obs. of 7 variables:
$ ID : Factor w/ 77 levels "9999","4431",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value : int -2 -1 -3 -1 -1 -2 -1 -1 -1 -1 ...
$ lagged_value : num -1.237 -1.237 -2.237 -1.237 -0.237 ...
$ Ambiguous_Valence : int 1 1 1 1 1 1 1 1 1 1 ...
$ Negative_Valence : num -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 ...
$ Positive_Valence : num -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 ...
$ Trait : num 0.796 0.796 0.796 0.796 0.796 ...
```

For below, I’m sorry, the Positive_Valence and Trait columns are too close together – I couldn’t figure out how to space them out without going onto the next line. 0.7958646 is the value for every row in the Trait column.

```
> head(data, 10)
ID value lagged_value Ambiguous_Valence Negative_Valence Positive_Valence Trait
1 9999 -2 -1.2372449 1 -0.5 -0.5 0.7958646
2 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
3 9999 -3 -2.2372449 1 -0.5 -0.5 0.7958646
5 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
7 9999 -1 -0.2372449 1 -0.5 -0.5 0.7958646
8 9999 -2 -1.2372449 1 -0.5 -0.5 0.7958646
9 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
10 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
11 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
12 9999 -1 -1.2372449 1 -0.5 -0.5 0.7958646
```

**Model with two-way interaction terms:**

Here is the model:

```
lmer(value ~ Negative_Valence*Lagged_Value + Positive_Valence*Lagged_Value + Ambiguous_Valence*Lagged_Value + Trait*Lagged_Value + (-1 + Lagged_Value |ID), data = data)
```

For the equations at each level, I have:

**Level 1:**

$$Y_{ti} = beta_{0} + beta_{1i}Value_{(t-10)i} + e_{ti}$$

where $beta_{0}$ is the global intercept and $beta_{1i}$ is the intercept in level-2 unit (participant) *i*. For this we have the level 2 model:

**Level 2:**

$$beta_{1i} = gamma_{10} + gamma_{11}Trait_{i} + gamma_{12}NegativeValence_{i} + gamma_{13}PositiveValence_{i} + gamma_{14}AmbiguousValence_{i} + u_{1i}$$

Where $gamma_{10}$ is the average intercept in level-2 unit (participant) *i*

**Composite:**

$$Y_{ti} = beta_{0} + gamma_{10}Value_{(t-10)i} + gamma_{11}(Trait_{i}*Value_{(t-10)i}) + gamma_{12}(NegativeValence_{i}* Value_{(t-10)i}) + gamma_{13}(PositiveValence_{i}*Value_{(t-10)i}) + gamma_{14}(AmbiguousValence_{i}*Value_{(t-10)i}) + e_{ti} + u_{1i}$$

This results in 8 estimates from the model, 6 fixed effects, $beta_{0}$, $gamma_{10}$, $gamma_{11}$, $gamma_{12}$, $gamma_{13}$, and $gamma_{14}$, and 2 random effects: $e_{ti}$ and $u_{1i}$

$beta_{0}$ is the global intercept; it is the mean of the time series when the fixed effects $Value_{(t-10)i}$, $NegativeValence_{i}$, $PositiveValence_{i}$, $AmbiguousValence_{i}$, and $Trait_{i}$ are all at zero.

$gamma_{10}$ represents the expected difference in the time series’ for a one unit change in the lagged value ($Value_{(t-10)i}$), when $Trait_{i}$, $NegativeValence_{i}$, $PositiveValence_{i}$, and $AmbiguousValence_{i}$ all equal zero.

$gamma_{11}$ represents the extent to which the relationship between the time series value ($Y_{ti}$) and the lagged value $Value_{(t-10)i}$ depends on the personality trait of interest ($Trait_{i}$), with $NegativeValence_{i}$, $PositiveValence_{i}$, $AmbiguousValence_{i}$ held constant

$gamma_{12}$ represents the extent to which the relationship between the time series value ($Y_{ti}$) and the lagged value $Value_{(t-10)i}$ depends on $NegativeValence_{i}$, with all other fixed effects ($Trait_{i}$, $PositiveValence_{i}$ and $AmbiguousValence_{i}$) held constant. And same for $gamma_{13}$ and $gamma_{14}$ with $PositiveValence_{i}$ and $AmbiguousValence_{i}$ respectively.

$u_{1i}$ is the random intercept for individuals and the software will estimate a variance for this (I am wondering if this term actually should not exist in these formulas because the model does not have a random intercept)

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

**Model with three-way interaction terms:**

Here is the model:

```
lmer(value ~ Negative_Valence*Trait*Lagged_Value + Positive_Valence*Trait*Lagged_Value + Ambiguous_Valence*Trait* Lagged_Value + (-1 + Lagged_Value |ID), data = data).
```

**Level 1:**

$$Y_{ti} = beta_{0} + beta_{1i}Value_{(t-10)i} + e_{ti}$$

where $beta_{0}$ is the global intercept and $beta_{1i}$ is the intercept in level-2 unit (participant) *i*. For this we have the level 2 model:

**Level 2:**

$$beta_{1i} = gamma_{10} + gamma_{11}Trait_{i} + gamma_{12}NegativeValence_{i} + gamma_{13}PositiveValence_{i} + gamma_{14}AmbiguousValence_{i} + gamma_{15}(NegativeValence_{i}*Trait_{i}) + gamma_{16}(PositiveValence_{i}*Trait_{i}) + gamma_{17}(AmbiguousValence*Trait_{i}) + u_{1i}$$

Where $gamma_{10}$ is the average intercept in level-2 unit (participant) *i*

**Composite:**

$$Y_{ti} = beta_{0} + gamma_{10} Value_{(t-10)i} + gamma_{11}(Trait_{i}*Value_{(t-10)i}) + gamma_{12}(NegativeValence_{i}*Value_{(t-10)i}) + gamma_{13}(PositiveValence_{i}*Value_{(t-10)i}) + gamma_{14}(AmbiguousValence_{i}* Value_{(t-10)i}) + gamma_{15}(NegativeValence_{i}*Trait_{i}*Value_{(t-10)i}) + gamma_{16}(PositiveValence_{i}*Trait_{i}*Value_{(t-10)i}) + gamma_{17}(AmbiguousValence*Trait_{i}*Value_{(t-10)i}) + e_{ti} + u_{1i}$$

This results in 11 estimates from the model, 9 fixed effects, $beta_{0}$, $gamma_{10}$, $gamma_{11}$, $gamma_{12}$, $gamma_{13}$, $gamma_{14}$, $gamma_{15}$, $gamma_{16}$, and $gamma_{17}$, and 2 random effects: $e_{ti}$ and $u_{1i}$

$u_{1i}$, $e_{ti}$, $beta_{0}$, $gamma_{10}$, $gamma_{11}$, $gamma_{12}$, $gamma_{13}$ and $gamma_{14}$ are defined as they are in the model above.

$gamma_{15}$ represents the degree to which the relationship between the time series value ($Y_{ti}$) and the lagged value $Value_{(t-10)i}$ depends on the interaction between $NegativeValence_{i}$ and the personality trait of interest ($Trait_{i}$), with all other fixed effects ($PositiveValence_{i}$ and $AmbiguousValence_{i}$) held constant. Similarly for $gamma_{16}$ and $gamma_{17}$ with $PositiveValence_{i}$ and $AmbiguousValence_{i}$ respectively.

Specific questions:

- Have I written the Level 1-2 formulas correctly to reflect how I built the models?
- Have I explained the coefficients in the model correctly, especially for the interaction terms?
- Have I reflected the fact that my models have a random slope for the lagged variable, but no random intercept? My hunch is that maybe the term $u_{1i}$ should not exist in these formulas – is that the case?
- Is the random slope on the lagged variable reflected in $beta_{1i}$?
- Do $NegativeValence_{i}$, $PositiveValence_{i}$, and $AmbiguousValence_{i}$ have the correct subscripts? They actually do not vary based on the individual; they vary based on the stimulus number (i.e., trial number), but this level is not included in our models as described above.

0 Asked on December 11, 2021 by isobel-m

1 Asked on December 10, 2021 by code_diy

3 Asked on December 8, 2021 by skoestlmeier

2 Asked on December 8, 2021 by unistudent87

3 Asked on December 8, 2021 by rockthestar

1 Asked on December 8, 2021

1 Asked on December 8, 2021 by kev8484

32 Asked on December 8, 2021

0 Asked on December 8, 2021

0 Asked on December 8, 2021 by likao

0 Asked on December 8, 2021

0 Asked on December 8, 2021 by thetagang

0 Asked on December 8, 2021

categorical data generalized linear model multiple regression regression

0 Asked on December 8, 2021

2 Asked on December 8, 2021 by sadisha

1 Asked on December 8, 2021

machine learning multiple regression regression standardization

0 Asked on December 8, 2021

machine learning neural networks q learning references reinforcement learning

1 Asked on December 8, 2021 by user292136

1 Asked on December 6, 2021 by hulk

Get help from others!

Recent Questions

- How Do I Get The Ifruit App Off Of Gta 5 / Grand Theft Auto 5
- Iv’e designed a space elevator using a series of lasers. do you know anybody i could submit the designs too that could manufacture the concept and put it to use
- Need help finding a book. Female OP protagonist, magic
- Why is the WWF pending games (“Your turn”) area replaced w/ a column of “Bonus & Reward”gift boxes?
- Does Google Analytics track 404 page responses as valid page views?

Recent Answers

- haakon.io on Why fry rice before boiling?
- Joshua Engel on Why fry rice before boiling?
- Lex on Does Google Analytics track 404 page responses as valid page views?
- Jon Church on Why fry rice before boiling?
- Peter Machado on Why fry rice before boiling?

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP