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

Dears,

 

I am analyzing the results of subjects through the time. At each time we take two measurements from the subject that are correlated between them ( coded the two measurements in one variable X). The dependent variable is the change of results from first time point (chg). The predictors are the results from first time point (first), X, time and interaction between X and time. I want to take into account the correlation of the two measurements from X in the model. For that reason, I have the following 4 models. Note that models 1 and 2 have the same results. The same happens for models 3 and 4. My questions are, what is the difference between those 4 models (i.e: how could I explain the models to a non statistical audience)? why do I get same results in models 1 vs 2 and 3 vs 4?

/*model 1*/

proc sort data= data; by subjid X time;run;

Proc mixed data=data;

Class subjid X time;

Model chg=first X time X*time/ ddfm=kenwardroger solution;

Repeated X(time)/subject=subjid type=CS ;

LSmeans time*X;

Run;

/*model 2*/

proc sort data= data; by subjid X time;run;

Proc mixed data=data;

Class subjid X time;

Model chg=first X time X*time/ ddfm=kenwardroger solution;

Repeated time(X)/subject=subjid type=CS ;

LSmeans time*X;

Run;

/*model 3*/

proc sort data= data; by X subjid time;run;

Proc mixed data=data;

Class subjid X time;

Model chg=first X time X*time/ ddfm=kenwardroger solution;

Repeated time/subject=subjid(X) type=CS ;

LSmeans time*X;

Run;

/*model 4*/

proc sort data= data; by subjid X time;run;

Proc mixed data=data;

Class subjid X time;

Model chg=first X time X*time/ ddfm=kenwardroger solution;

Repeated time/subject=X(subjid) type=CS ;

LSmeans time*X;

Run;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

> why do I get same results in models 1 vs 2 and 3 vs 4?

 

SAS converts CLASS variables and interactions between CLASS variables into dummy variables in a design matrix. The nested interaction A(B) is the same as B(A), which is also the same as A*B, where "the same" means that each interaction term generates the same columns of a design matrix, although the columns might be in different orders. The SAS documentation shows the dummy variables for nest interactions,

 

The doc says, "The nesting operator in SAS/STAT software is more of a notational convenience than an operation distinct from crossing. Nested effects are typically characterized by the property that the nested variables never appear as main effects. The order of the variables within nesting parentheses is made to correspond to the order of these variables in the CLASS statement. The order of the columns is such that variables outside the parentheses index faster than those inside the parentheses, and the rightmost nested variables index faster than the leftmost variables."

 

 

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

> why do I get same results in models 1 vs 2 and 3 vs 4?

 

SAS converts CLASS variables and interactions between CLASS variables into dummy variables in a design matrix. The nested interaction A(B) is the same as B(A), which is also the same as A*B, where "the same" means that each interaction term generates the same columns of a design matrix, although the columns might be in different orders. The SAS documentation shows the dummy variables for nest interactions,

 

The doc says, "The nesting operator in SAS/STAT software is more of a notational convenience than an operation distinct from crossing. Nested effects are typically characterized by the property that the nested variables never appear as main effects. The order of the variables within nesting parentheses is made to correspond to the order of these variables in the CLASS statement. The order of the columns is such that variables outside the parentheses index faster than those inside the parentheses, and the rightmost nested variables index faster than the leftmost variables."

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 673 views
  • 0 likes
  • 2 in conversation