Page 1 of 1

How to create a product variable?

Posted: Fri Sep 06, 2013 2:35 pm
by stollbej
Dear Forum,

I am currently trying to model a moderated multilevel mediation model with MLwiN.
For this purpose I am using selection variables (dummies coded 1,0) similar to the multivariate chapter in the 2012 MLwiN manual.
Now, this selection variable needs to be multiplied with each explanatory variable in my model and my question would be how to do that? Does one simply use the "compute" template to multiply two variables or is there another way?

Thanks very much for your assistance!

Best regards,
Jake

Re: How to create a product variable?

Posted: Fri Sep 06, 2013 2:51 pm
by ChrisCharlton
You can do this either with the calculate window (Data Manipulation->Calculate) or directly with the CALC command, which is described in the MLwiN help file. If the purpose is to exclude certain rows of data from the analysis you can also do this with the EXCL command or within the hierarchy viewer (Model->Hierarchy Viewer->Options).

Re: How to create a product variable?

Posted: Fri Sep 13, 2013 9:38 am
by stollbej
Hi Chris,

Thank you very much for your reply, I just noticed!
My model is similar to a multivariate model where I basically have two models in one. Let´s say, I have two DV's and different IV's for each but want to estimate both together in one model. The dummies (or selection variables) serve the purpose to "trick" the software into doing this. For that purpose I have to multiply each IV with the proper dummy (or selection variable) for each outcome. My question then was how to create such a product variable e.g. multiply a dummy with an IV so that I can run this multivariate model. If this would work using the calculate window this would be great.
Does that sound like this would make sense?

Thanks for your assistance,
Jake

Re: How to create a product variable?

Posted: Fri Sep 13, 2013 10:04 am
by ChrisCharlton
The easiest way to do this might actually be to set up the model as multivariate in MLwiN (see chapter 14 of the user manual: http://www.bristol.ac.uk/cmm/software/m ... al-web.pdf). When you do this MLwiN expands the data in a manner similar to that which you describe and generates a resp and resp_indicator variable to indicate which response each row corresponds to.

To directly answer your question, if you want to multiply a variable with a dummy to create a new variable you could do something like the following in the command window:

CALC c100 = 'iv' * 'dummy'

for each independent variable, changing c100 to a free column where you want to store the result.

Re: How to create a product variable?

Posted: Fri Sep 13, 2013 11:34 am
by stollbej
Thanks very much for your quick reply!

I read the chapter, however, this would include adding another level to the model for the selection variables there. I am trying to follow recommendations of another article and will try that first!

Thank you for your help, very kind!

Jake