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

The following SAS procedures did not work. Look forward to your help.

The code:

data Activity;                                                                                                                                                                                                                                                      
  length treatment $20;
  input treatment$ block Km Vmax;                                                                                                                                                                                                                                  
  datalines;
  Non-Antibiotics 5 46.18 28.06
  Non-Antibiotics 3 55.61 24.64
  Non-Antibiotics 4 58.71 27.35
  Non-Antibiotics 3 47.32 22.15
  Non-Antibiotics 4 43.61 12.53
  Non-Antibiotics 8 52.00 25.94
  Non-Antibiotics 11 54.65 21.34
  Non-Antibiotics 5 64.54 25.73
  Non-Antibiotics 10 51.27 24.36
  Non-Antibiotics 5 57.61 23.04
  Non-Antibiotics 5 48.37 32.42
  Non-Antibiotics 9 56.04 40.59
  Non-Antibiotics 6 53.89 11.33
  Antibiotics 8 39.02 27.74
  Antibiotics 4 55.56 16.92
  Antibiotics 7 56.97 25.41
  Antibiotics 9 58.29 31.49
  Antibiotics 4 53.18 28.04
  Antibiotics 11 41.89 43.48
  Antibiotics 5 40.35 38.12
  Antibiotics 3 54.84 40.96
  Antibiotics 10 47.66 32.51
  Antibiotics 6 61.14 35.47
  Antibiotics 5 52.42 38.02
  ;
  run;
Proc print data=Activity;
run;
proc glimmix data=Activity nobound; 
  class treatment block;
  model Km = treatment; 
  random block/subject=treatment*block type=cs residual;
  random _residual_/subject=treatment*block group=treatment; 
  lsmeans treatment/tdiff lines;
  covtest homogeneity;
run;

The results:

111.png

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

One other point - the random _residual_ statement with the subject=treatment*block doesn't do anything, as there are several blocks without replication of treatment. 

so you could remove that statement.  Also, the test for homogeneity is no longer applicable, as I removed the group= option.

 

SteveDenham 

View solution in original post

3 REPLIES 3
SteveDenham
Jade | Level 19

The two random statements lead to problems.  The first says to treat the blocks as random, with correlated errors by block, while the second adds in an overdispersion factor, and the errors are heteroscedastic by treatment.  Try simplifying the model to something like:

 

proc glimmix data=Activity nobound; 
  class treatment block;
  model Km = treatment; 
  random intercept/subject=block;
  random _residual_/subject=treatment*block; 
  lsmeans treatment/tdiff lines;
  covtest homogeneity;
run;

I removed the group= option as the estimates you presented differed by less than 5%, so I don't think you have good evidence for separate estimates for the residual VC.  I also changed the first statement to a G side random effect.  Give this a shot, and check the results to see if they make sense.  If you still catch the QUANEW issue you may have to relax your convergence criteria, or add in a method= statement to switch to RMPL (residual marginal pseudo-likelihood).

 

SteveDenham

 

SteveDenham
Jade | Level 19

One other point - the random _residual_ statement with the subject=treatment*block doesn't do anything, as there are several blocks without replication of treatment. 

so you could remove that statement.  Also, the test for homogeneity is no longer applicable, as I removed the group= option.

 

SteveDenham 

kellychan84
Fluorite | Level 6

Thank you so much @SteveDenham ! Your reply really help! The reason I am testing homogeneity is that my supervisor wants to see this data. And if I removed the group option in my random_residual_statement, the homogeneity data will not show up. You mentioned in your reply that "or add in a method= statement to switch to RMPL (residual marginal pseudo-likelihood)" , I do not have experience in this statement and don't know whether it will help to get the homogeneity data by adding this to my coding.  

 

And by catching this great opportunity, can I ask you another question. 

To analyse my data, I first used the code blow. It did not work at first, but when I added parms statement, it worked. And I also try your coding suggestions, it also work. But the result is a bit different. Which should I choose to be more accurate. 

My SAS code:

data Activity;                                                                                                                                                                                                                                                      
  length treatment $20;
  input treatment$ block Km Vmax;                                                                                                                                                                                                                                  
  datalines;
  Non-Antibiotics 5 46.18 28.06
  Non-Antibiotics 3 55.61 24.64
  Non-Antibiotics 4 58.71 27.35
  Non-Antibiotics 3 47.32 22.15
  Non-Antibiotics 4 43.61 12.53
  Non-Antibiotics 8 52.00 25.94
  Non-Antibiotics 11 54.65 21.34
  Non-Antibiotics 5 64.54 25.73
  Non-Antibiotics 10 51.27 24.36
  Non-Antibiotics 5 57.61 23.04
  Non-Antibiotics 5 48.37 32.42
  Non-Antibiotics 9 56.04 40.59
  Non-Antibiotics 6 53.89 11.33
  Antibiotics 8 39.02 27.74
  Antibiotics 4 55.56 16.92
  Antibiotics 7 56.97 25.41
  Antibiotics 9 58.29 31.49
  Antibiotics 4 53.18 28.04
  Antibiotics 11 41.89 43.48
  Antibiotics 5 40.35 38.12
  Antibiotics 3 54.84 40.96
  Antibiotics 10 47.66 32.51
  Antibiotics 6 61.14 35.47
  Antibiotics 5 52.42 38.02
  ;
  run;
Proc print data=Activity;
run;
proc glimmix data=Activity nobound; 
  class treatment block;
  model Km = treatment; 
  random block/subject=treatment*block type=cs residual;
  parms (-8.6732) (52.0395);
  lsmeans treatment/tdiff lines;
  covtest "block=0" 0 .;
  output out=second predicted=pred residual=resid residual(noblup)=mresid 
  student=sresid student(noblup)=smresid;
run;
proc print data=second;
run;
proc sgplot data=second;
  scatter y=smresid x=pred;
  refline 0;
run;
proc sgplot data=second;
  scatter y=smresid x=treatment;
  refline 0;
run;
proc sgplot data=second;
  vbox smresid/group=treatment datalabel;
run;
proc sgscatter data=second;
  plot sresid*(pred treatment block);
run;
proc univariate data=second normal plot;
  var sresid;
  histogram sresid / normal kernel;
run;

Result:

kellychan84_0-1595949869257.png

Adapting your code by change a bit to GLMM statement:

proc glimmix data=Activity nobound; 
  class treatment block;
  model Km = treatment; 
  random intercept/subject=block;
  lsmeans treatment/tdiff lines;
  covtest "block=0" 0 .;
  output out=second predicted=pred residual=resid residual(noblup)=mresid 
  student=sresid student(noblup)=smresid;
run;

Result:

kellychan84_1-1595950001170.png

Great thanks!!!

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 4015 views
  • 3 likes
  • 2 in conversation