I hope someone can help me to do this correctly:
To start with the easier part, let’s say I have 2 variables:
y is my outcome and has been measured at 3 time points for each individual.
x is my predictor measured at the same three time points for each individual.
So, we have something like this:
Like this, I should be able to fit a multilevel model where the relationship between y and x can vary between individuals and between time point. Thus:
y ~ x + (1 + x|id) + (1 + x|time)
But what if I now have another variable
z that has only been measured once. If I want to include this variable into above regression model, I also have to put it into the dataframe shown above. So we get this:
I could now fit this model:
y ~ x + z + (1 + x|id) + (1 + x|time)
But, something must be off here: The dataframe indicates that the variable
z has been measured 3 times as well and that the value is the same for each measurement. That means we have 3 times as much data in this variable compared to reality. So, the regression model probably estimates now a much smaller SD for the posterior of the beta value for z, simply because it assumed 3x as much data for this specific variable.
Is there any way to “tell” the model that this value has only been measured once? How exactly can I solve this problem?