BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
obrienfk
Calcite | Level 5

Hi all.

I have two 2-level independent variables: Gender (0 and 1) and Group (0 and 1) and a continuous DV: Score.

For my full model, I ran the following analysis:

PROC GLM DATA = mydata;

     CLASS Gender Group;

     MODEL Score = Gender Group Gender*Group

RUN;

Just out of interest, I calculate an interaction between the two variables myself (by using this formula: "Interaction = Gender*Group") and ran this model:

PROC GLM DATA = mydata;

     CLASS Gender Group Interaction; *It makes no difference if "Interaction" is in the class section;

     MODEL Score = Gender Group Interaction;

RUN;

The weird thing is that these produced different results! The results for the interaction were the same in each, but the individual main effects were very different. The reason that I am interested in this is that with PROC REG, the latter kind of model is the only possible one. And indeed, the results from PROC REG match the results from the second model above, and not the first (more automatic) one.

What gives? Am I calculating the interaction incorrectly?

Best,

Fearghal

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The asterisk in the interaction syntax doesn't really mean the product of the variable values. It implies the combinations of the class variable levels and generates multiple dummy variables in the design matrix. In your calculation of interaction, the terms (Gender; Group) = (0;0), (0;1) and (1;0) all correspond to interaction=0. To get the proper dummy variables in your design matrix, use proc glmmod :

PROC GLMMOD DATA = myData outParm=parms outDesign=myDesign;

     CLASS Gender Group;

     MODEL Score = Gender Group Gender*Group;

RUN;

Check out the parms and myDesign datasets. You can then use the myDesign dataset with proc reg, if you wish.

PG

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

The asterisk in the interaction syntax doesn't really mean the product of the variable values. It implies the combinations of the class variable levels and generates multiple dummy variables in the design matrix. In your calculation of interaction, the terms (Gender; Group) = (0;0), (0;1) and (1;0) all correspond to interaction=0. To get the proper dummy variables in your design matrix, use proc glmmod :

PROC GLMMOD DATA = myData outParm=parms outDesign=myDesign;

     CLASS Gender Group;

     MODEL Score = Gender Group Gender*Group;

RUN;

Check out the parms and myDesign datasets. You can then use the myDesign dataset with proc reg, if you wish.

PG

PG
obrienfk
Calcite | Level 5

Thanks for that really clear response PG. Given that the asterisk in the GLM syntax doesn't literally mean the product of, does this mean that in general, one should not create an interaction in a regression model through such a simple product manner? - I feel like people do this all the time Or is my situation just a special case where the product and the asterisk syntax in GLM give different results?

PGStats
Opal | Level 21

Interactions between continuous variables can be created as simple products (XY = X*Y;). Interactions between CLASS variables should not.

PG

PG
obrienfk
Calcite | Level 5

That's really interesting and good to note. Thanks!

PGStats
Opal | Level 21

Check the documentation for GLM parameterization at SAS/STAT(R) 9.3 User's Guide 

for more details.

PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2970 views
  • 2 likes
  • 2 in conversation