BookmarkSubscribeRSS Feed
ltwedgar
Calcite | Level 5

In the case for 2-way manova, how can I test whether the two groups are significant or not?

i.e. I want to to something like this,

 

proc glm data=t;

class gp1 gp2;

model y1 y2 y3 = gp1 gp2;

manova h=gp1 gp2;

run;

 

It happens that SAS will give me two seperate tests, one for testing whether gp1 is significant, the other for testing whether gp2 is significant. But I want to test whether gp1 and gp2 are both significant (i.e. Ho(model 0): y1 y2 y3= , H1(model 1): y1 y2 y3=  gp1 gp2).

2 REPLIES 2
JacobSimonsen
Barite | Level 11

I agree that this test doesn't is not calculated by PROC GLM.

 

Here is my approach. Since the maksimum of the log-likelihood is just -n*log(determinant(E))/2+constant, where E is the error-matrix, it is just to let proc glm output the error matrix into a dataset. Do this for both model, and then calculate the likelihood ratio value manually. The pvalue is calculated by using that the 2 x difference in log-likelihood is chi-square distributed. I think there is a slightly better approach where it is used that  some transformation of the ratio is exact F-distributed, but I cant find this in my notes from univerversity.

 

here is an example. It is neccessary to take determinant, so I therefor use the matrix-package here (Matrix-Package). Alternatively it can be done with PROC IML.

 

Of some reason this site will not show my code correct, so I therefore also attach it in a separate file

 

data simulation;
  do gp1=1 to 4;
  do gp2=1 to 4;
  do i=1 to 5;
   y1=rannor(-1);
   y2=rannor(-1);
   y3=rannor(-1);
   output;
   end;
  end;
  end;
run;

ods output errorsscp=sscp0;
proc glm data=simulation;
class gp1 gp2;
model y1 y2 y3 = gp1 gp2;
manova h=gp1 gp2/printe ;
run;
quit;

ods output errorsscp=sscp1;
proc glm data=simulation;
model y1 y2 y3 = ;
manova /printe;
run;
quit;

 

data _NULL_;
  array sigma0{3,3} _temporary_ ;
  array sigma1{3,3} _temporary ;
  dsid0= open('sscp0');
  dsid1= open('sscp1');
  do i=1 to 3;
    rc= fetchobs(dsid0,i);
    rc= fetchobs(dsid1,i);
 do j=1 to 3;
   sigma0[i,j]=getvarn(dsid0,2+j);
   sigma1[i,j]=getvarn(dsid1,2+j);
 end;
  end;
  call show(sigma0);
  put;
  call show(sigma1);
  d0=determinant(sigma1);
  d1=determinant(sigma0);
  likelihoodratio=80*(log(d0)-log(d1));/*n=80 in this example*/

  put d0= d1= likelihoodratio=;
  pvalue=sdf('chisquare',likelihoodratio,3*(  ((4-1)+(4-1)+1)-1));/*third argument is the difference in parameters*/;
  put pvalue= pvalue6.4;
run;

 

ltwedgar
Calcite | Level 5
It is unfortunate that proc glm cannot solve this problem. Appreciate your effort of making use of likelihood ratio to approximate the F test. However, I think the most simplest way to solve this is to create dummy variables and use proc reg and mtest statement to conduct the F test.

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 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
  • 2 replies
  • 1340 views
  • 1 like
  • 2 in conversation