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

Hi,

 

I have some questions about the difference between repeated measurements and nested models. For repeated measurements, we have different times nested within one id. For usual examples of nested models, we have different subjects nested within one school or states. So do they have any difference?

 

For example, if the id is nested within the city, and the city is nested within states. I wrote down the following codes. Are they equivalent? (It seems that they are not equivalent because SAS just stopped because of too many iterations for the first one) I don’t know why they are different.

 

proc mixed data=hello1217;

      class unitid control State city;

      model rate=control/solution;

      random unitid(city) city(state) State;

run;

 

proc mixed data=hello1217;

      class unitid control State city;

      model rate=control/solution;

      random unitid(city) city /subject=state;

run;

 

Also, if we have repeated measurements in time, for the following code, are they equivalent?

 

proc mixed data=test;

      class time;

      model y=x/solution;

      random time /subject=id;

run;

 

proc mixed data=test;

      class time;

      model y=x/solution;

      random time(id) id;

run;

 

Thank you!

 

Wenru

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

1. A full understanding of the design structure is your guide. Generally, you do not include a specification for the residual variance in MIXED, because MIXED expects to set residual variance to be equal to some variance source that is "left over". If there is nothing left over, then various problems arise. In your study, the variance among unitid nested within city nested within state is the residual variance and should not be included in a RANDOM statement.

 

2. In SAS syntax, 

 

random state*city unitid(city);  

 is, in most cases, equivalent to

 

random city(state) unitid(city);

 

 

3.

random intercept city / subject=state;

 is equivalent to

 

random state state*city;

which is equivalent to

 

random state city(state);

 

View solution in original post

4 REPLIES 4
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

If your observations are measured at the unitid level, then your first model 

 

 

proc mixed data=hello1217;
      class unitid control State city;
      model rate=control/solution;
      random unitid(city) city(state) State;
run;

probably fails to run because it is over-specified. Try

 

 

 

proc mixed data=hello1217;
      class unitid control State city;
      model rate=control/solution;
      random city(state) State;
run;

which leaves unitid(city) to be residual.

 

 

In your second model 

 

      random unitid(city) city /subject=state;

is equivalent to 

 

random state*city unitid(city);

To mimic the first model, use

 

  random intercept city / subject=state;

In your third model, replace

 

      random time /subject=id;

with

 

      repeated time / subject=id;

I recommend reading Modelling covariance structure in the analysis of repeated measures data and SAS® for Mixed Models, Second Edition for the details you need.

 

I hope this helps.

 

 

 

 

ZHWR7125
Fluorite | Level 6

Hi, thank you so much for your reply! I am still confused and would you please help me with the questions below?

 

1. For the first model, you said that it is over-specified. How can we know if the model is overspecified by random terms? (I have around 8000 observations in this dataset, one observation per unitid)

 

2. For the second model, you said that 

 

random unitid(city) city /subject=state; 

 

is equivalent to 

 

random state*city unitid(city);

 

I think that the city is nested within state, so why can we add an interaction term between them?

 

To mimic the first one, you said that

 

random intercept city / subject=state;

 

Is intercept equivalent to unitid? Why don't we let it be nested within the city? Subject= State means that they are nested with in state, right?

 

Thank you very much for your generous help!

 

Wenru

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

1. A full understanding of the design structure is your guide. Generally, you do not include a specification for the residual variance in MIXED, because MIXED expects to set residual variance to be equal to some variance source that is "left over". If there is nothing left over, then various problems arise. In your study, the variance among unitid nested within city nested within state is the residual variance and should not be included in a RANDOM statement.

 

2. In SAS syntax, 

 

random state*city unitid(city);  

 is, in most cases, equivalent to

 

random city(state) unitid(city);

 

 

3.

random intercept city / subject=state;

 is equivalent to

 

random state state*city;

which is equivalent to

 

random state city(state);

 

ZHWR7125
Fluorite | Level 6

Thanks a lot! Your solution is so helpful! Sorry for the late reply.

 

Wenru

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 3505 views
  • 2 likes
  • 2 in conversation