Hello,
I am trying to recreate a BLUP animal model from Tempelman, R. J. and Rosa, G. J. M. Empirical Bayes Approaches to Mixed Model Inference in Quantitative Genetics. In: Genetic Analysis of Complex Traits Using SAS. Saxton, A. (Editor). Cary, NC: SAS Institute Inc., 2004.
They used a pedigree of 306 animals, out of which 282 animals have phenotypic records (y). The model has one fixed effect (generation) and one random effect (animal) with a covariance structure given by a relationship matrix (306x306). The most important bit of the code is:
proc mixed data=meyer noprofile;
class generation animal;
model y = generation /solution noint covb;
random animal /type=lin(1) LDATA=L2data solution; *L2data is an adjusted output from proc inbreed;
parms (40) (50) /noiter;
run;
The code works, but the problem is that I am getting only 282 solutions (breeding values), whereas the original contains 306 solutions.
Original dimensions:
My dimensions:
So, the real question is if I can make SAS to create the Z matrix with all 306 columns. Also, is this a version issue? I am using SAS 9.4, but I guess the authors created the code about 25 years ago.
Thank you!
Ok, I think you can get the full Z matrix if you use PROC GLIMMIX to fit the mixed model. Have a look at this note: 40631 - How can I save the X and Z matrix from PROC MIXED or PROC GLIMMIX to a data set? (sas.com).
In the code specified, you are including a random effect for each animal in your study. In general, if there are 282 animals with non-missing phenotypic records, you will get 282 random effects. I don't have access to the book you have referenced, so I'm not sure if the authors did some extra step to account for the missing data in the other 24 animals.
Hello Mike,
I could send you the source files, but I see no extra step in the code the authors provided. Here is the whole code:
options ls = 75 ps = 60 nodate pageno=1 ;
/* Input pedigree file Animal id in first field, sire id in second field, dam id in third field. If sire or dam is unknown, indicate with period '.' */
data pedigree; infile 'E:\meyer.ped'; input animal sire dam; run;
proc inbreed data=pedigree covar outcov=amatrix; var animal sire dam; run;
/* Input dataset with animal (1-306), generation (1 or 2) and y (data) Include base animals (1-24) with missing records (y = .) */ data meyer; infile 'E:\meyer.dat'; input animal generation y; run;
/* Row numbers needed to be provided for pipelining numerator relationship matrix (A)from PROC INBREED into PROC MIXED */ data L2DATA; set amatrix; parm = 1; row = _n_; run;
/* Posterior inference on fixed and random effects treating variance components as known */ proc mixed data=meyer noprofile; class generation animal; model y = generation /solution noint covb; random animal /type=lin(1) LDATA=L2data solution; parms (40) (50) /noiter; ods listing exclude solutionr; ods output solutionr = solutionr; run;
Ok, I think you can get the full Z matrix if you use PROC GLIMMIX to fit the mixed model. Have a look at this note: 40631 - How can I save the X and Z matrix from PROC MIXED or PROC GLIMMIX to a data set? (sas.com).
Thank you, Mike. Actually, the original code works as intended (due to the pedigree matrix, I get solutions even for the animals without observations), but I made coding mistake. So, I can use both PROC MIXED and PROC GLIMMIX to obtain the same results. However, saving the matrices in GLIMMIX is a great feature and it is going to be really helpful for me.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.