# Solved – Group level random effect

In a lab experiment Participants took part in four different treatment. At the beginning of each session they were randomly assigned to groups of 4 and played repeated public goods game for 30 periods.

So far I have collapsed the data to obtain group averages, so that observation in a period are independent. This data was used to estimate a model with group-level random effects. Since in some groups there were participants whose incentives were different than those of other members of their group, I would like to test whether difference in incentives lead to disparities in behaviour.

Would it be OK for me to split the group average into two observations:

• With the decisions made by the "special" individuals
• with the average of 3 others

The same random effect would be assigned to both.

Contents

## Short answer & R Formula

I believe the R code you're looking for is something along the lines of the following, from the `lme4` package.

`myModel <- lmer(y ~ incentive + (1 | treatGroup/player), data = df)`

Basically you're saying that there's a random effect for each player, who is nested inside of a treatment group with a random effect. In addition, there is a fixed effect for `incentive`.

First of all, I personally find the terms "fixed effect" and "random effect" to be confusing and used somewhat inconsistently. Andrew Gelman (Prof. at Columbia) has a great blog post on the topic.

### Model formulation

So in lieu of using those terms, I'll try to write out the (basic) formulation based on what I understand from your question. In particular, it sounds like we have:

• 16 players (indexed by \$i\$)
• 30 observations per player (indexed by \$j\$)
• 4 possible groups (indexed by \$k\$)
• A binary "incentive" treatment \$M\$, where \$m_{i(k)} = 1\$ if the \$i\$-th player receives the incentive

Let \$Y_{ij(k)}\$ be the \$j\$-th observation for the \$i\$-th player, who is placed into the \$k\$-th group.

With these in mind, our regression model is as follows:

\$\$Y_{ij(k)} sim N(mu_{i(k)}, sigma^2)\$\$

\$\$mu_{i(k)} = alpha_i + alpha_k + beta cdot m_{i(k)}\$\$

### Explanation of terms / quick notes

We have a few relevant terms:

• \$alpha_i\$: The 'baseline' for this player
• \$alpha_k\$: the effect of being in the \$k\$-th group
• \$beta\$: The impact of the `incentive` treatement

Some quick notes:

• Using `(1 | treatGroup / player)` describes a nesting between levels (e.g., each player is in only one treatment group).

• To your point in the comments, 30 observations for each player are assumed to be drawn from a common distribution – Our goal is to estimate the impact of (a) incentives and (b) treatment group on the mean of that distribution.

• This answer assumes no interaction between the incentive and the treatment group.

• I used this to refresh my memory on `lmer` syntax since I'm more accustomed to using `rstan` (link).
• Also see this CV post on `lmer` formula syntax