SHAZAM Community
Ask Your Question
0

How do I generate a dummy variable which is a composite of other dummy variables?

asked 2015-01-30 01:12:08 +0000

Tolu gravatar image

I have a few dummy variables in my dataset and I want to generate a 4th dummy which combines the other 3. How do I do this in Shazam?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-01-30 17:23:29 +0000

You can use the GENR command to add any variables together. Below is a more detailed example using Dummy variables (see the manual). Remember when using them in a regression be careful of the Dummy Variable Trap.

* Generating 3 example types of dummy variables
* Note that the DUM(X) function variable is one when X > 0, 0 otherwise
genr d1=dum(3)  
genr d2=dum(time(0)-6) 
genr d3=dum(consume-income-1)

* Create a dummy as combination
genr d4 = d1+d2+d3

* Print the 4 variables
print d1-d4 / nobyvar

The output from this is:

 |_* Generating 3 example types of dummy variables
 |_* Note that the DUM(X) function variable is one when X > 0, 0 otherwise
 |_genr d1=dum(3)
 |_genr d2=dum(time(0)-6)
 |_genr d3=dum(consume-income-1)

 |_* Create a dummy as combination
 |_genr d4 = d1+d2+d3

 |_* Print the 4 variables
 |_print d1-d4 / nobyvar
       D1             D2             D3             D4
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00  0.0000000E+00   1.000000
    1.000000      0.0000000E+00  0.0000000E+00   1.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-01-30 01:12:08 +0000

Seen: 693 times

Last updated: Jan 30 '15