Page 1 of 1

Lagged Independent Variables?

Posted: Mon Nov 13, 2017 10:25 am
by yurisantino
Greetings! I have a brief question on how to enter lagged variables.

I have a small two-level model where participants (=level2) responded on 3 to 5 measurement occasions (=level1). I'm trying to model:

dependent variable = constant + daily "x" + lagged dependent variable (from the day before).

So I'm trying to see whether the relationship between x and y holds after I control for the measure of Y the day before.

Is there anyone that can help me and provide guidance? :mrgreen:

Thank you!

EDIT: I think lagged is the wrong word for it! sorry!

Re: Lagged Independent Variables?

Posted: Mon Nov 13, 2017 11:30 am
by ChrisCharlton
As with other software you would just need to create a second, lagged version, of the variable of interest and enter this into the model. MLwiN provides a command (MLLAG - also available via Data Manipulation->Multilevel Data Manipulations) to help with the creation of this within each cluster, although you will still need to ensure that variable is sorted, all time occasions are present, etc.

Re: Lagged Independent Variables?

Posted: Mon Nov 13, 2017 12:52 pm
by yurisantino
Thank you kindly Chris for your response!

What exactly do you mean with sorted? I sometimes have only 3 measurement occasions for a person and sometimes 5, is that problematic?

So if I understand correctly, I have to do the following:

Multilevel Data Manipulations
-> operation: lags
-> on blocks defined by: person identifier
-> add to action lost
-> execute

Or am I missing something here, because I did not sort the variables? I assumed they were because the day variable is coded as 1, 2, 3, 4, 5 for al participants.

Thanks again Chris!

Re: Lagged Independent Variables?

Posted: Mon Nov 13, 2017 1:06 pm
by ChrisCharlton
Yes, that looks like the correct use of the dialogue box.

The thing that you need to watch out for is that the command is just using the value from the previous row within the cluster, so if the rows were in the order occasions 3, 2, 1, 4, 5 for example then it would not pick up the correct values to lag as it would be assuming 1, 2, 3, 4, 5. Because of this you would need to ensure that the data was sorted by occasions within person.

If you were missing a measurement, e.g. 1,2,4,5 then the third lagged value would be based on occasion 2 instead of 3 (which doesn't exist and should perhaps be missing). In that case you might consider expanding the data so that there were rows for each possible occasion with person. If you had 1, 2, 3 and were missing 4, 5 then the problem shouldn't occur.

I would suggest examining the new lagged variable after it is created to ensure that it matches your expectations.

Re: Lagged Independent Variables?

Posted: Mon Nov 13, 2017 1:45 pm
by yurisantino
Thank you very much for your help Chris! I think I understand now :-)

Best wishes,

Yuri