## How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Solved
Occasional Contributor
Posts: 6

# How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Hi all,

Say you have two continuous variables, size and number of eggs laid. These are both measured once for each individual in an experiment.  Each individual belongs to a family. In addition, individuals in a family are reared on one of two food treatments (each individual is given only one of these treatments for the duration of the experiment). Family is treated as a random effect and food as a fixed effect.

I would like to know how food treatment changes the covariance parameter estimates for the two variables, with family as the subject of the covariance parameter estimates.

To produce the covariance parameter estimates for the two traits whilst ignoring food treatment my code is as follows.

A dummy variable, ‘variable’, details if a measurement is for size or number of eggs laid, with column y as the value of that variable.  ‘number’ is the specific ID given to each individual.

Proc mixed data=mylib.mydata;

Class family variable number;

y = variable;

random variable /type=un sub=family g gcorr;

repeated /type=un sub=family*number;

run;

Any suggestions would be greatly appreciated.

Accepted Solutions
Solution
‎03-30-2015 01:11 PM
Posts: 2,655

## Re: How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Observation 1: You may want to shift to PROC GLIMMIX, as I doubt strongly that egg count follows a normal distribution.  You may want to look at Example 44.5 in the PROC GLIMMIX (SAS/STAT13.2) documentation for Joint Modeling of Binary and Count Data, except here size is probably normal.  Still, the methodology should hold.

Observation 2:  This is really why you want to move to GLIMMIX.  Try something like:

proc glimmix data=yourdata;

class family variable number food;

model y=food variable food*variable / noint s dist=byobs(variable);

random _residual_/subject=number group=food;

covtest homogeneity;

run;

This treats the two y variables as coming from separate distributions (see the documentation on how to handle this), but correlated within number.  It also fits separate variances for the food groups, and through the COVTEST provides a test of homogeneity.  I would recommend a negative binomial distribution for the egg count variable.

Steve Denham

All Replies
Solution
‎03-30-2015 01:11 PM
Posts: 2,655

## Re: How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Observation 1: You may want to shift to PROC GLIMMIX, as I doubt strongly that egg count follows a normal distribution.  You may want to look at Example 44.5 in the PROC GLIMMIX (SAS/STAT13.2) documentation for Joint Modeling of Binary and Count Data, except here size is probably normal.  Still, the methodology should hold.

Observation 2:  This is really why you want to move to GLIMMIX.  Try something like:

proc glimmix data=yourdata;

class family variable number food;

model y=food variable food*variable / noint s dist=byobs(variable);

random _residual_/subject=number group=food;

covtest homogeneity;

run;

This treats the two y variables as coming from separate distributions (see the documentation on how to handle this), but correlated within number.  It also fits separate variances for the food groups, and through the COVTEST provides a test of homogeneity.  I would recommend a negative binomial distribution for the egg count variable.

Steve Denham

Occasional Contributor
Posts: 6

## Re: How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Many thanks for your response Steve. This essentially answers my question although something is still unclear to me.

As far as I understand, you have removed the G side random effects that I had in my original code (for family), and have left only the R side random effects (for individual). Is there a particular reason for this? As I would like to know how food changes the covariance parameter estimates for the two variables with family as the subject (not individual), is it possible to include another random statement, for family, and apply the covtest statement specifically to the family random effect?

So the random statements for GLIMMIX would look something like:

random variable  / subject = family group=food type=un;

random _residual_/subject=family(number) group=food type=un;

Posts: 2,655

## Re: How to detect if a treatment changes the covariance parameter estimates for two variables with a random effect as the subject using proc mixed

Sorry to be so late in replying, but vacay got in the way.

In my opinion, your two random statements would be precisely what is needed.  Hopefully you have enough data to be able to get good estimates for these.

Steve Denham

🔒 This topic is solved and locked.