BookmarkSubscribeRSS Feed
F_Roca
Calcite | Level 5

Hi everyone,

I'm doing some research in animal science and I have a problem that I need help with. It might be very simple to do it manually but I would like to find a way to do it in SAS.

Lets assume

variable1= breed1, breed2, breed3, breed4

variable2=breed4, breed5

Now, lets assume the variable Liveweight (LW)  at a particular time t is affected by age, variable1, variable2 and you are using the variable 'milk' as a covariable for the model.

Your model in proc mixed goes something like this:

LW= age variable1 variable2 variable1*variable2 variable1*milk / solutions;

On your SAS output you get your 'Solutions for fixed effects' table with the regression coefficients of 'milk" on breed1, breed2, breed3, and breed4 (b1 b2 b3 b4); your standar errors (SE), DF, etc.

In this table you know if the coefficients are different from 0 but i would like to know...How the different reg coefficient for the different breeds compare to each other or put in other words how they differ from each other.

I've extracted the table with the ods output statement and selected only the regression coefficient but I'm stuck there. I know that my t value is equal to the difference of lets say of b1-b2/SE of (b1-b2), after that I can look at my t values on a table and find out which ones differ from the others but doing this manually is taking me forever since I have to run the variable LW at different times (LW5, LW10, LW15... LW365).

Can anybody help me to find a way to do this more efficiently and correctly in SAS? Any assistance would be greatly appreciated.

Thanks,

JR

4 REPLIES 4
SteveDenham
Jade | Level 19

Try fitting the following:

model LW=age variable1 variable2 variable1*variable2 variable1*milk / solutions NOINT;

The solutions for variable1*milk will now be the slopes for each maternal breed.

A second think to think about is that your LW variables are strongly autocorrelated, so that getting separate point and avariability estimates at each time point may lead to some problems.  You may wish to start considering a repeated measures model.  And of course, that could mean a time-varying covariate in milk production.

Could you post a very small sample of your data?  I think you may want to consider the following model, provided that age accurately indexes each of the live weights:

proc mixed;

class age variable1 variable2 subjectid:

model LW = age|variable1|variable2 variable1*milk/solution noint;

repeated age/subject=subjectid type=sp(pow)(age1);/*I chose the spatial power structure because I was not sure if the time points were evenly spaced.  If they are, replace with ARH(1) to accommodate change in variance over time */

run;

Good luck.

Steve Denham

F_Roca
Calcite | Level 5

Hi Steve,

My data would be something like this:

subject time  milk    variable1 variable2    LW

1          90     503     breed1     breed5     120

2          90     460     breed3     breed5     136

3          90     751     breed4     breed6     156

4          90     607     breed2     breed5     174

5          90     447     breed3     breed6     136

6          90     614     breed1     breed6     133

7          90     422     breed2     breed5     126

8          90     528     breed4     breed6     142

9          90     721     breed1     breed6     148

10        90     560     breed3     breed5     150

...

In this dataset i'm using the ' milk at day 90' however I want to run the same LW variable (at day 90) but also with milk60 and milk40 as covariables, of course in separate models.

I'm interested in the regression coefficients of milk*variable1 and at some point also the milk*variable1*variable2. However I cannot manage to write a program that could tell me if this coefficients are different from each other.

SteveDenham
Jade | Level 19

OK.  So let's do the simpler model first.  We need to predict LW at day90 as a function of milk, variable1, and variable2.

data one; /* made up data that doesn't even come close to the biological data */
do variable1 = 1 to 3;
do variable2 =4 to 6;
  do obs = 1 to 4;
milk=abs(500*rannor(1));
lw=abs(120*rannor(1));
output;
end;
end;
end;
run;

proc mixed data=one;
class variable1 variable2;
model lw=variable1|variable2 variable1*variable2*milk/solution noint e;
estimate 'Slope variable1=1, variable2=4 vs variable1=1, variable2=5' variable1*variable2*milk 1 -1 0  0 0 0  0 0 0;
run;

The F test for variable1*variable2*milk is for homogeneity of slopes across the combinations of variable1 and variable2.  If this is significant, then at least one slope is different.  To compare the slopes, the estimate statement is inserted.  A contrast statement will work as well, and does have the advantage of multiple contrasts and controlling for them.

Note that the three-way interaction with the covariate is all that I included, because at this point I am testing for equal slopes across all combinations of variable1 and variable2.  If you are only interested in the slopes within variable1 or variable2, drop back to that.  Be very careful about including more than one interaction of the covariate with the class variables, as the lower order terms do not really mean "slope".  A really good read is SAS for Mixed Models, 2nd. ed. by Littell et al., especially the chapter on analysis of covariance.

Hope this gets you started.

Steve Denham


F_Roca
Calcite | Level 5

Thanks Steve that was very helpful and for sure i'll give that reference a good read.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3896 views
  • 3 likes
  • 2 in conversation