```Date: Tue, 8 Jun 2010 09:48:09 -0500 Reply-To: Robin R High Sender: "SAS(r) Discussion" From: Robin R High Subject: Re: Using the CONTRAST Statement in PROC MIXED for 3 fixed effects Comments: To: Anne In-Reply-To: <201006081148.o58AkqCD027660@willow.cc.uga.edu> Content-Type: text/plain; charset="US-ASCII" Anne, This question leads into one of my favorite topics, but before I demonstrate it, will quickly show the "usual" way of writing a contrast or estimate in MIXED. Your verbal descriptions assume the three-factor interaction is necessary. I also would further examine the repeated correlation structure, esp. with both a RANDOM and REPEATED statements entered as given, but that is beyond the scope of this note. proc mixed data = t; class subject treatment group time; model hydration = treatment group time; repeated group time / subject = subject type = un@un; random subject/ subject = subject; run; First, note the order of variables placed on the CLASS statement and the order and number of their levels Class Level Information Class Levels Values treatment 4 10 20 30 K group 3 1 2 3 time 2 24h 3h The order of the levels for treatment and time may be different from what you expect, but that is how SAS interprets your coding. Here 3h implies level of time = 2 From top to bottom, write out the levels in the following heirarchy: treatment 10 20 30 K group 1 2 3 1 2 3 1 2 3 1 2 3 time 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 Your verbal description for the first one: treatment K vs. treatment 10 for group 1 at time 3h With the 3-factor interaction on the MODEL statement, 4 of terms contain treatment, so need 1 and -1 at respective comparison levels of treatment PROC MIXED; MODEL hydration = treatment | group | time; ESTIMATE 'k vs 10 | g=1, tm=2' treatment -1 0 0 1 treatment*group -1 0 0 0 0 0 0 0 0 1 0 0 treatment*time 0 -1 0 0 0 0 0 1 treatment*group*time 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0; etc... Given this statement works, the others are straightforward to edit by examining the factors and placement of levels. However, one of my new "favorite" topics is to demonstrate the LSMESTIMATE statement from GLIMMIX which makes it much easier to compute contrasts of the LSMEANS, first starting with your verbal descriptions: Note, that GLIMMIX doesn't work with the type of REPEATED statement you chose so this extension may not be relevant, but is an excellent lead-in to showing how to write non-positional parameter inputs in GLIMMIX (also available on the ESTIMATE and CONTRAST statements) Write out your descriptions of desired contrasts: 1. treatment K vs. treatment 10 for group 1 at time 3h 2. treatment K vs. treatment 20 for group 1 at time 3h 3. treatment K vs. treatment 30 for group 1 at time 3h For "contrast" number 1., enter two sets of closed brackets and add the -1 and 1 coefficients in each followed by a comma and with placeholders for all 3 variables: [-1, . . . ] [1, . . . ] The first contrast 1. states you want to compare level 4 with level 1 of treatment (first variable) [-1, 4 . .] [1, 1 . . ] Enter the stated levels of the other two variables: [-1, 4 1 2] [1, 1 1 2] The LSMESTIMATE tatement allows for multiple contrasts, so easy to edit the other two by changing treatment '1' to '2' and '3': 1. [-1, 4 1 2] [1, 1 1 2] 2. [-1, 4 1 2] [1, 2 1 2] 3. [-1, 4 1 2] [1, 3 1 2] ^^^ Then add all three sets into the LSMESTIMATE statement followed by a comma and include the 3-factor interaction and descriptions, also add options cl and adjust=.... PROC GLIMMIX; MODEL hydration = treatment | group | time; ... LSMESTIMATE treatment*group*time 'K vs 10 |grp=1, time 2' [1, 4 1 2] [-1, 1 1 2], 'K vs 20 |grp=1, time 2' [1, 4 1 2] [-1, 2 1 2], 'K vs 30 |grp=1, time 2' [1, 4 1 2] [-1, 3 1 2] / cl adjust=simulate(nsamp=40000 seed=121121); run; You'll see the output for this one statement gives the same results as writing _3_ rather tedious ESTIMATE statements with all the 0's and 1's, plus it will also will compute multiple comparison adjustmens ... usually simulate is a good choice here. I've found many situations recently where familiarity with this coding leads to great efficiency and ease in making the desired comparisons of LSMEANS, esp, when you have multiple coefficients across factor levels and they aren't just 1 and -1 and 0. Robin High UNMC From: Anne To: SAS-L@LISTSERV.UGA.EDU Date: 06/08/2010 07:00 AM Subject: Using the CONTRAST Statement in PROC MIXED for 3 fixed effects Sent by: "SAS(r) Discussion" Hello, First of all I would like to introduce my study. I have a study population divided into 3 different groups. For each group each subject got 4 different treatments to the skin at two different points in time. Now I want to analyze whether the group, the treatment and the time has any influence on the skin hydration. The data have the following structure (the points in between shall show that there are more subjects than two subjects in each group): data t; input subject Treatment\$ group\$ time\$ hydration; cards; 1 K 1 3h 0.424301601 1 10 1 3h 0.66230796 1 20 1 3h 0.935552903 1 30 1 3h 0.314342945 1 K 1 24h 0.193648359 1 10 1 24h 0.226547532 1 20 1 24h 0.555516816 1 30 1 24h 0.420854877 2 K 1 3h 0.894045221 2 10 1 3h 0.666443159 2 20 1 3h 0.984863413 2 30 1 3h 0.920030913 2 K 1 24h 0.144518192 2 10 1 24h 0.203838493 2 20 1 24h 0.638158456 2 30 1 24h 0.576927595 . . . . . . . . . . . . . . . 9 K 2 3h 0.924301601 9 10 2 3h 1.16230796 9 20 2 3h 1.435552903 9 30 2 3h 0.814342945 9 K 2 24h 0.693648359 9 10 2 24h 0.726547532 9 20 2 24h 1.055516816 9 30 2 24h 0.920854877 10 K 2 3h 1.394045221 10 10 2 3h 1.166443159 10 20 2 3h 1.484863413 10 30 2 3h 1.420030913 10 K 2 24h 0.644518192 10 10 2 24h 0.703838493 10 20 2 24h 1.138158456 10 30 2 24h 1.076927595 . . . . . . . . . . . . . . . 17 K 3 3h 1.024301601 17 10 3 3h 1.26230796 17 20 3 3h 1.535552903 17 30 3 3h 0.914342945 17 K 3 24h 0.793648359 17 10 3 24h 0.826547532 17 20 3 24h 1.155516816 17 30 3 24h 1.020854877 18 K 3 3h 1.494045221 18 10 3 3h 1.266443159 18 20 3 3h 1.584863413 18 30 3 3h 1.520030913 18 K 3 24h 0.744518192 18 10 3 24h 0.803838493 18 20 3 24h 1.238158456 18 30 3 24h 1.176927595 . . . . . ; run; To get the global effect I run the following repeated measure analysis of variance: proc mixed data = t; class subject treatment group time; model hydration = treatment group time; repeated group time / subject = subject type = un@un; random subject/ subject = subject; run; Now I am interested e.g. in the p-value of the differences in the means of the pairwise comparisons, for example treatment K vs. treatment 10 for group 1 at time 3h, treatment K vs. treatment 20 for group 1 at time 3h and treatment K vs. treatment 30 for group 1 at time 3h. As far as I know, I have to take the CONTRAST statement but I have some problems to formulate the contrast correctly. Can anyone help me with the contrasts? Thanks a lot, Anne ```

Back to: Top of message | Previous page | Main SAS-L page