I'd like to fit a multiple membership model in which clusters are crossed on some dichotomous variable X. There will be a random effect for cluster when X = 0 as well as a random effect for cluster when X = 1. These two random effects will covary. My specific question focuses on what structure should be specified using the TYPE option of the RANDOM statement to model this covariance in the G matrix.
The variables in my dataset are as follows:
y: continuous outcome
x: dichotomous variable
participant: participant ID
cluster1-cluster2: clusters participant interacts with (there are six clusters)
weight1-weight2: weights for clusters (both 0.50)
Code to generate an example data set is placed behind the spoiler block below.
data WORK.D;
infile datalines dsd truncover;
input y:BEST12. x:BEST12. participant:$5. cluster1:BEST12. cluster2:BEST12. weight1:BEST12. weight2:BEST12.;
format y BEST12. x BEST12. cluster1 BEST12. cluster2 BEST12. weight1 BEST12. weight2 BEST12.;
datalines4;
1.7116292881,0,01,1,3,0.5,0.5
-5.933128683,0,02,1,6,0.5,0.5
-13.5337454,0,03,1,4,0.5,0.5
7.8635381751,0,04,1,2,0.5,0.5
4.375759951,0,05,1,3,0.5,0.5
-2.805837926,0,06,1,5,0.5,0.5
-4.125339503,0,07,1,5,0.5,0.5
-4.502606231,0,08,1,2,0.5,0.5
-3.07787325,0,09,1,2,0.5,0.5
-8.712734561,0,010,1,4,0.5,0.5
3.5771897824,0,011,2,6,0.5,0.5
-5.569639235,0,012,2,3,0.5,0.5
5.0164446473,0,013,2,5,0.5,0.5
0.9662273736,0,014,2,6,0.5,0.5
-3.053160929,0,015,2,6,0.5,0.5
5.7631686365,0,016,2,6,0.5,0.5
-4.061618169,0,017,1,2,0.5,0.5
-5.675804875,0,018,2,6,0.5,0.5
-1.998492309,0,019,1,2,0.5,0.5
-4.877700179,0,020,2,4,0.5,0.5
0.5826871124,0,021,3,5,0.5,0.5
1.5678925913,0,022,2,3,0.5,0.5
-1.662167585,0,023,3,5,0.5,0.5
-1.852380966,0,024,1,3,0.5,0.5
-1.306121158,0,025,3,6,0.5,0.5
0.1193967378,0,026,2,3,0.5,0.5
-4.690690418,0,027,3,4,0.5,0.5
-7.514667431,0,028,3,5,0.5,0.5
1.2045188081,0,029,3,4,0.5,0.5
1.1362348613,0,030,3,4,0.5,0.5
-3.448389572,0,031,4,5,0.5,0.5
-4.637042638,0,032,4,5,0.5,0.5
-5.800713663,0,033,4,5,0.5,0.5
-10.46251835,0,034,4,5,0.5,0.5
-3.226708786,0,035,3,4,0.5,0.5
-0.108735954,0,036,1,4,0.5,0.5
1.4564796198,0,037,4,5,0.5,0.5
5.3981391556,0,038,3,4,0.5,0.5
5.044206624,0,039,2,4,0.5,0.5
-4.990751737,0,040,1,4,0.5,0.5
4.4013568068,0,041,2,5,0.5,0.5
2.8935250611,0,042,3,5,0.5,0.5
4.3287629943,0,043,1,5,0.5,0.5
-7.972389136,0,044,1,5,0.5,0.5
5.6880095481,0,045,4,5,0.5,0.5
5.2309207532,0,046,2,5,0.5,0.5
-5.75182201,0,047,2,5,0.5,0.5
-0.391128977,0,048,1,5,0.5,0.5
0.8261384611,0,049,3,5,0.5,0.5
0.5012871882,0,050,5,6,0.5,0.5
-2.502664486,0,051,2,6,0.5,0.5
-2.283545937,0,052,4,6,0.5,0.5
5.667798606,0,053,2,6,0.5,0.5
2.6738632685,0,054,4,6,0.5,0.5
-0.348288503,0,055,5,6,0.5,0.5
-0.721466022,0,056,1,6,0.5,0.5
-3.347618332,0,057,1,6,0.5,0.5
-0.543900391,0,058,3,6,0.5,0.5
1.7437789482,0,059,4,6,0.5,0.5
2.2261827522,0,060,4,6,0.5,0.5
-4.027513544,1,11,1,3,0.5,0.5
2.4456106753,1,12,1,2,0.5,0.5
1.7491766973,1,13,1,6,0.5,0.5
3.8937891424,1,14,1,2,0.5,0.5
-1.687468755,1,15,1,5,0.5,0.5
-3.464784494,1,16,1,3,0.5,0.5
-0.094955504,1,17,1,6,0.5,0.5
-2.894264012,1,18,1,4,0.5,0.5
-0.01356603,1,19,1,6,0.5,0.5
-4.708004753,1,110,1,4,0.5,0.5
-3.392529479,1,111,2,3,0.5,0.5
-3.817671171,1,112,1,2,0.5,0.5
3.0014733968,1,113,2,4,0.5,0.5
-1.56760315,1,114,2,5,0.5,0.5
-5.872920416,1,115,2,4,0.5,0.5
3.7860683279,1,116,1,2,0.5,0.5
2.7506424395,1,117,2,6,0.5,0.5
-9.507855019,1,118,2,5,0.5,0.5
-5.690620937,1,119,2,5,0.5,0.5
-1.502637305,1,120,2,5,0.5,0.5
0.6257569539,1,121,1,3,0.5,0.5
4.1823693449,1,122,3,6,0.5,0.5
-0.988326345,1,123,3,4,0.5,0.5
-0.519023566,1,124,3,4,0.5,0.5
-5.893752026,1,125,2,3,0.5,0.5
0.8888285888,1,126,1,3,0.5,0.5
-4.85976943,1,127,1,3,0.5,0.5
3.8821360339,1,128,3,6,0.5,0.5
1.740925357,1,129,2,3,0.5,0.5
-2.360578263,1,130,3,4,0.5,0.5
0.48730412,1,131,2,4,0.5,0.5
-4.090089012,1,132,4,5,0.5,0.5
-4.981695651,1,133,4,6,0.5,0.5
6.9505380042,1,134,4,6,0.5,0.5
5.3731396082,1,135,4,6,0.5,0.5
2.161390774,1,136,4,6,0.5,0.5
-9.882399516,1,137,4,5,0.5,0.5
-1.364193916,1,138,3,4,0.5,0.5
-0.601594245,1,139,2,4,0.5,0.5
-3.166185748,1,140,4,6,0.5,0.5
-2.247222929,1,141,1,5,0.5,0.5
4.3654810524,1,142,5,6,0.5,0.5
2.5255637516,1,143,5,6,0.5,0.5
0.3662445094,1,144,5,6,0.5,0.5
-2.467531122,1,145,4,5,0.5,0.5
-7.228769228,1,146,1,5,0.5,0.5
2.5481005061,1,147,2,5,0.5,0.5
-2.546195615,1,148,2,5,0.5,0.5
-2.222218085,1,149,2,5,0.5,0.5
-2.864998875,1,150,3,5,0.5,0.5
1.5270292508,1,151,1,6,0.5,0.5
1.137488738,1,152,1,6,0.5,0.5
1.6653747585,1,153,5,6,0.5,0.5
4.9831078878,1,154,5,6,0.5,0.5
10.437312685,1,155,4,6,0.5,0.5
4.5063732354,1,156,3,6,0.5,0.5
5.1041559153,1,157,2,6,0.5,0.5
-2.311161319,1,158,4,6,0.5,0.5
5.0289995693,1,159,5,6,0.5,0.5
-4.905688138,1,160,5,6,0.5,0.5
;;;;
Here is the PROC GLIMMIX code that has gotten me closest to where I'd like to be:
proc glimmix data=D;
class cluster1-cluster2;
effect clusterg1=mm(cluster1-cluster2/weight=(weight1-weight2));
model Y = X /dist=normal link=identity;
random clusterg1 clusterg1*X / G;
run;
The G matrix from this model is as follows:
What's missing are the covariances between random effects, which I've indicated with light gray cells. I have not been able to find a covariance structure in the list of TYPE options that matches this scenario. Can PROC GLIMMIX work in this situation?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.