DATA Step, Macro, Functions and more

Modeling and generate output PROC MIXED

Reply
Frequent Contributor
Posts: 103

Modeling and generate output PROC MIXED

[ Edited ]

Good night SAS friends:

 

Here i come to get some help:

 

i have this data base:

 

data have;
input ANIMAL SIRE trait1 trait2 trait3 WEIGH_AT_BIRTH  ;
cards;
    2818     851     118       1       1    10.3
    2819     851     118       1       1     9.8
    2820     851     118       1       1     9.2
    2821     851     118       1       1    10.4
    2822     851     118       1       1     9.2
    2823     851     118       1       1    10.9
    2824     851     118       1       1     9.3
    2825     851     118       1       2    10.2
    2826     851     118       1       2    10.2
    2827     851     118       1       2      10
    2828     851     118       1       2     8.3
    2829     851     118       1       2     9.2
    2830     851     118       1       2       9
    2831     851     118       1       2     8.5
    2835     851     118       2       1      10
    2836     851     118       2       1     9.1
    2837     851     118       2       1     8.1
    2838     851     118       2       1     9.3
    2839     851     118       2       1      10
    2840     852     118       2       1     9.2
    2841     852     118       2       1     9.6
    2842     852     118       2       1     8.2
    2843     852     118       2       2     8.2
    2844     852     118       2       2      10
    2845     852     118       2       2     8.3
    2852     852     119       1       1     9.4
    2853     852     119       1       1    10.5
    2854     852     119       1       1    11.3
    2855     852     119       1       1    10.6
    2856     852     119       1       1       9
    2857     852     119       1       1    10.5
    2858     852     119       1       1      10
    2859     852     119       1       1    10.2
    2860     852     119       1       1    10.4
    2861     852     119       1       1    10.3
    2862     852     119       1       1      10
    2863     852     119       1       1    10.3
    2864     852     119       1       2    11.2
    2865     852     119       1       2     9.4
    2866     852     119       1       2      10
    2867     852     119       1       2    11.2
    2868     852     119       1       2    11.4
    2869     852     119       1       2      11
    2870     852     119       1       2      11
    2871     852     119       1       2     9.4
    2872     852     119       1       2    12.3
    2873     852     119       1       2     8.7
    2877     852     119       2       1      10
    2878     852     119       2       1     9.2
;

 

As you know, i work modeling quantitative genetics, and the last posts i made here were associated to construct some data bases, that the're already working, now is time for modeling, aiming to choose the model that fits to the trait we are working at:

 

Here is the problem to solve:

 

Using the data base "have"  i need to construct this table here:

 

FIXED EFFECT TRAIT SIRE_ESTIMATE RESIDUAL_ESTIMATE AIC trait1 trait2 trait3
trait1 WEIGH_AT_BIRTH 0.2251 0.6686 125.8 0.5751 . .
trait2 WEIGH_AT_BIRTH 0.1934 0.6994 128.2 . 0.0017 .
trait3 WEIGH_AT_BIRTH 0.1728 0.8691 138.3 . . 0.8567
trait1 – trait2 WEIGH_AT_BIRTH 0 0.6482 121.1 0.0063 0.0497 .
trait1 – trait3 WEIGH_AT_BIRTH 0.2353 0.6815 126.7 0.0367 . 0.7583
trait2 – trait3 WEIGH_AT_BIRTH 0.2019 0.7097 128.8 . 0.0016 0.5912
trait1 – trait2 – trait3 WEIGH_AT_BIRTH 0 0.6618 122 0.0074 0.0522 0.8199

 

the information used to fill the table above, is obtained by ANOVA, using PROC MIXED,  to test the variance for one, two and three fixed effects, manually i would have to add and erase some of them in the MODEL STATEMENT and, i came here to make it easier to obtain this information:

 

To explain the methodology, i will use the model that uses 2 fixed effects (trait1 and trait3) in the model,but in the table we have all possible conbinations between the fixed effects, this is the modeling part that manually would be like 2 weeks at work, and SAS can help, im sure of it.

 

To explain the variance associated to the trait, the trait we are studing is WEIGHT_AT_BIRTH, and the statement used to get this variance analisys is:

 

proc mixed data=have method=reml covtest cl;
class trait1 trait2 trait3; /*Note that we are using all three fixed effects*/
model WEIGH_AT_BIRTH = trait1 trait3 /ddfm=kenwardroger;  /*Here we just use the traist we want to test*/
random sire / solution;  /*The random effect never changes*/
run;

 

This estatement offers many tables, and in those tables are the data we need to extract:

 

In the table called: "Covariance Parameter Estimates" we find the Estimate for sire and residual, and these numbers are used to fill the SIRE_ESTIMATE and RESIDUAL_ESTIMATE, (RED) respectivly, as you can see in the results table:

 

Covariance Parameter Estimates
Cov Parm Estimate Standard Error Z Value Pr > Z Alpha Lower Upper
SIRE 0.2353 0.5465 0.43 0.3334 0.05 0.03019 29445057
Residual 0.6815 0.1437 4.74 0.0001 0.05 0.4688 1.0811

 

the Other information is the AICC (Smaller is Better) information, used to choose the best model that fits into the trait, and this value (GREEN)

 

Fit Statistics
-2 Res Log Likelihood 122.7
AIC (Smaller is Better) 126.7
AICC (Smaller is Better) 127
BIC (Smaller is Better) 122.7

 

And finishing, the significant estatistics p-value is used to know if the fixed effect is affecting the trait, this value goes to the results table (BLUE), too:

 

Type 3 Tests of Fixed Effects
Effect Num DF Den DF F Value Pr > F
trait1 1 9.3 5.94 0.0367
trait3 1 45.2 0.1 0.7583

 

as you can see, it is not the onlye result we have to introduce in the table, the model estatement shoud be changing continuously like this:

 

proc mixed data=have method=reml covtest cl;
class trait1 trait2 trait3;
(1) model WEIGH_AT_BIRTH = trait1 /ddfm=kenwardroger;

(2) model WEIGH_AT_BIRTH = trait2 /ddfm=kenwardroger;

(3) model WEIGH_AT_BIRTH = trait3 /ddfm=kenwardroger;

(4) model WEIGH_AT_BIRTH = trait1 trait2 /ddfm=kenwardroger;

(5) model WEIGH_AT_BIRTH = trait1 trait3 /ddfm=kenwardroger;

(6) model WEIGH_AT_BIRTH = trait2 trait3 /ddfm=kenwardroger;

(7) model WEIGH_AT_BIRTH = trait1 trait2 trait3 /ddfm=kenwardroger;
random sire / solution;
run;

 

I need this working, with more that 3 fixed effects, the RANDOM EFFECT will always be SIRE, because we are working in growing parameters for sheep genetic improvement.

 

Imagine make this manually, existing SAS taht is offering this help, i tell you this my friends because two years ago, when i was beginig to work in this field, i studied 512 models manually, now knowing those procedures of SAS programing can improve modeling with better results.

 

Thank you very much

 

 

Super User
Posts: 17,750

Re: Modeling and generate output PROC MIXED

This may be a useful reference for you:

 

http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/

Frequent Contributor
Posts: 103

Re: Modeling and generate output PROC MIXED

Reeza good night and Thanks for your contribution:

i am studing this seminar, and the last example is exactly what i was looking for, well it need some modifications, i began this and unfortunately already stoped here:

i can make the loop for single model:

%macro mymixed(num);
  %do i = 1 %to #
    title "dependent variable is v&i";
    proc mixed data=have;
      model v1 = trait&i;
    run;
  %end;  
%put &i;
%mend;
%mymixed(3)

here, to continue can you help me to code the bi and three  multi trait:

where:

model v1 = trait1 trait2;
model v1 = trait1 trait3;
model v1 = trait2 trait3;
model v1 = trait1 trait2 trait3;

Thanks

Ask a Question
Discussion stats
  • 2 replies
  • 206 views
  • 1 like
  • 2 in conversation