02-25-2013 12:53 AM
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.
variable1= breed1, breed2, breed3, breed4
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.
02-25-2013 01:22 PM
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:
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 */
02-25-2013 05:11 PM
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.
02-26-2013 07:30 AM
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;
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;
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.