Programming the statistical procedures from SAS

Multiple random effects

Reply
Contributor
Posts: 25

Multiple random effects

Hi!

 

Is it possible to test multiple random effects in the estimate statement?

 

I have a mixed model with two random statements.

The model runs with no problem, but when I try to set up a lsmeans in the estimate statement SAS the problem starts...

 The log says:

"ERROR: SUBJECT contrasts not permitted with multiple RANDOM statements; the ESTIMATE statement is ignored."

 

It seems like there is not possible to have multiple random statements! ? 

Is this correct? Or is there a way around this problem?

 

 

The progam looks something like this:

Proc mixed data=data1;

class ID TRT Age fcode;

model weight = LEG0(TRT) LEG1(TRT) LEG2(TRT) Age index / noint solution DDFM=satterthwaite ;
random fcode /solution;
random LEG0 LEG1 /subject=ID solution;
*    estimate    "TRT1 lsmeans"        
        index 108.8
        AGE    0.2    0.2    0.2    0.2    0.2    
        LEG0(trt)     0.7071    0    0    0
        LEG1(trt)    -1.2247    0    0    0        
        LEG2(trt)    1.5811    0    0    0        
        LEG3(trt)    -1.8709    0    0    0
        | LEG0 0.7071 Leg1 -1.2247 / sub 0    0.05    0    0    0    0.05    0    0    0.05    0    0    0    0    0    0    0.05    0.05    0    0    0    0    0    0.05    0    0    0.05    0    0    0.05    0    0    0    0    0    0.05    0.05    0    0    0    0.05    0    0    0    0    0    0    0    0    0.05   ;
run;

 

Contributor
Posts: 25

Re: Multiple random effects

Is it nobody who knows anything about this?

SAS Super FREQ
Posts: 3,547

Re: Multiple random effects

[ Edited ]

Maybe @StatDave_sas or @sld might know.

PROC Star
PROC Star
Posts: 188

Re: Multiple random effects

It does seem like something someone here could help with.

 

I'd be happy to try if you'll provide more detail about your experiment, something like a Methods section that defines the variables and describes how the experiment was conducted.

 

Also please describe what you are attempting to do with your ESTIMATE statement. It is possible to have multiple random effects in the ESTIMATE statement but the presence of random effects produces a BLUP (rather than a BLUE) and the "size" of the inference space is determined by the random effects that are or are not included. Chapter 6 in

https://www.sas.com/store/books/categories/usage-and-reference/sas-for-mixed-models-second-edition/p...

and Chapter 9 in

https://www.crcpress.com/Generalized-Linear-Mixed-Models-Modern-Concepts-Methods-and-Applications/St...

are good resources if you are unfamiliar with BLUPs.

 

 

 

 

Contributor
Posts: 25

Re: Multiple random effects

Hi sId! Thank you for your reply!

 

Our data consist of repeated body weight records of 80 heifers. Body weight was recorded every second week from 3 to 15 months of age. The heifers were assigned to four different treatments (20 heifers in each group).

 

Legendre polynomials (Leg0 - Leg2) were fitted within treatment groups (TRT), and we attempt to include a random effect of ensilage (fcode) and also a random effect of individual (id).  We have constructed a random regression model in BLUP without an additive relationship matrix on the random effects. The repeated statement was used as the individuals have repeated records, and heterogeneous error variance was by age group.

What we attempt to do is to use the ESTIMATE statement to test hypotheses for treatment effects at a given time point. We are well aware that by correcting for random effects, the power of the test will be better, but we don’t know how to do to this in SAS.

 

 

Explanation:

id = 80 heifers

TRT = 4 different treatment groups

fcode = effect of feed batch (26 different batches)

agegr = 5 different age groups to correct for heterogeneous variance

LEG0, LEG1, LEG2 = Legendre polynomials of 1st, 2nd and 3rd order to fit the data

 

(The model is simplified)

 

 

 

Proc mixed data=data1;

class ID TRT fcode agegr;

model BW = LEG0(TRT) LEG1(TRT) LEG2(TRT) / noint solution DDFM=satterthwaite ;

random fcode /solution;

random LEG0 /subject=ID solution;

repeated /subject=ID TYPE=VC grp=agegr;

 

estimate    "TRT 1"       

            LEG0(trt)     0.7071    0    0    0

            LEG1(trt)    -1.2247    0    0    0       

            LEG2(trt)     1.5811    0    0    0       

      | LEG0 0.7071 / sub  0    0.05    0    0    0    0.05    0    0    0.05    0    0    0    0    0    0    0.05    0.05    0    0    0    0    0    0.05    0    0    0.05    0    0    0.05    0    0    0    0    0    0.05    0.05    0    0    0    0.05    0    0    0    0    0    0    0    0    0.05   ;

 

estimate    "TRT  2"         

            LEG0(trt)   0      0.7071     0     0

            LEG1(trt)   0     -1.2247     0     0          

            LEG2(trt)   0     1.5811     0     0          

      | Leg0 0.7071 / sub 0   0     0     0.05  0     0     0.05  0     0     0     0      0.05  0     0     0.05  0     0     0     0.05  0     0.05  0     0     0     0.05      0     0     0     0     0     0.05  0     0     0     0     0     0.05  0     0.05      0     0     0     0     0     0.05  0.05  0     0     0     0.05  0     0     0      0     0     0     0     0.05  0.05  0     0.05  0     0     0     0     0     0.05      0.05  0.05  0     0     0     0     0     0     0     0     0.05  0     0    

;

 

estimate    "TRT 3"          

            LEG0(trt)   0     0     0.7071      0    

            LEG1(trt)   0     0     -1.2247     0          

            LEG2(trt)   0     0     1.5811      0          

      | Leg0 0.7071 / sub 0.05      0     0     0     0     0     0     0.05  0     0      0.05  0     0     0.05  0     0     0     0     0     0.05  0     0     0     0.05      0     0     0.05  0     0     0.05  0     0     0     0     0     0     0     0.05      0     0     0.05  0.05  0.05  0     0     0     0     0     0     0     0.05  0      0.05  0     0     0     0     0     0     0     0     0.05  0.05  0.05  0     0      0     0     0     0.05  0     0     0.05  0     0     0.05  0     0     0     0

;

 

estimate    "TRT 4"

            LEG0(trt)   0     0     0     0.7071

            LEG1(trt)   0     0     0     -1.2247          

            LEG2(trt)   0     0     0     1.5811           

      |Leg0 0.7071 / sub 0    0     0.05  0     0.05  0     0     0     0     0.05  0      0     0.05  0     0     0     0     0.05  0     0     0     0.05  0     0     0      0     0     0.05  0     0     0     0.05  0.05  0.05  0     0     0     0     0      0     0     0     0     0.05  0     0     0.05  0.05  0     0     0     0.05  0      0     0     0     0.05  0     0     0     0     0     0     0     0.05  0     0      0     0     0     0     0     0     0.05  0.05  0     0     0     0.05  0.05

            ;    

 

run;

 

PROC Star
PROC Star
Posts: 188

Re: Multiple random effects

And thank you for the additional information.

 

Unfortunately, I have no experience with Legendre polynomials in this context. Googling around, I see that they are used in animal science in random regression analyses of growth and sussing out genetic and environmental effects. I'm not up to speed on these applications, so I'm not going to be able to be of any help. Sorry!

 

Because these polynomials are being used in a very specific context in animal science, my suggestion is that you track down someone in the animal science field with the expertise you need. Good luck!

 

 

SAS Super FREQ
Posts: 3,547

Re: Multiple random effects

@sld Just think of Legendre polynomials as alternative basis functions. They span the same space as 1, x, x**2, and x**3. Or think of them like splines.  

PROC Star
PROC Star
Posts: 188

Re: Multiple random effects

[ Edited ]

@Rick_SASSome of the papers I Googled up compare Legendre polynomials to B-splines (I'm thinking B-splines came out head, but wouldn't swear to it). And I did think of suggesting a spline alternative using the EFFECT statement (which you've been blogging about lately, thank you very much). But I've not done any random regressions with splines either; any advice I might offer would likely just drag us through the weeds....

 

It might be that writing ESTIMATE statements would be easier using GLIMMIX with the EFFECT statement for splines. 

Contributor
Posts: 25

Re: Multiple random effects

I don't think the use of Legendre polynomials is the problem in our case.

It just seems like SAS won't let us include more than one random effect in the ESTIMATE statement, regardless of type of variable.

 

I have written two exampes of RANDOM statements below. The MODEL run perfect in both exampes, but we have not been able to write the ESTIMATE statement without getting the following log:

ERROR: SUBJECT contrasts not permitted with multiple RANDOM statements; the ESTIMATE statement is ignored

 

RANDOM statement ex. 1:

....

random fcode /solution;

random LEG0 /subject=ID solution;

....

 

 

RANDOM statement ex. 2:
....

random LEG0 LEG1 /subject=ID solution;

...

PROC Star
PROC Star
Posts: 188

Re: Multiple random effects

[ Edited ]

Does the model for RANDOM statement ex. 2 include "random fcode / solution;" ? If not, does the ESTIMATE statement work?

 

If you drop "random fcode / solution;" from RANDOM statement ex. 1, does the ESTIMATE statement work?

Contributor
Posts: 25

Re: Multiple random effects

Ex.2 does not include "random fcode /solution;" an det ESTIMATE statement works.

If I drop "random fcode /solution;" from ex. 1 the ESTIMATE works.
PROC Star
PROC Star
Posts: 188

Re: Multiple random effects

Ah, well then, it does appear that "SUBJECT contrasts not permitted with multiple RANDOM statements".

 

Some ideas to get around that, of unknown validity:

 

Drop "random fcode;" if the variance estimate is small and you are comfortable assuming that it could be zero.

 

Move fcode to the MODEL statement as a fixed effect.

 

Compute the estimates you want by hand, using the fixed and random solutions.

 

 

Ask a Question
Discussion stats
  • 11 replies
  • 228 views
  • 0 likes
  • 3 in conversation