<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: contrast or lsmestimate in proc mixed in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849465#M42065</link>
    <description>&lt;P&gt;Yes, you could use the CONTRAST or LSMESTIMATE statement to make that particular comparison. The LSMESTIMATE statement is easier since you don't have to determine the correct contrast coefficients. But the interaction is really the "difference in difference" (DID) as discussed in &lt;A href="http://support.sas.com/kb/61830" target="_self"&gt;this note&lt;/A&gt;. This code does both:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed;
class a b;
model y=a|b;
lsmeans a*b;
lsmestimate a*b 'avg1,2,3 v 4' 1 1 1 -3 /e;
lsmestimate a*b 'did' 1 -1 -1 1 /e;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As for question 2, it might help to use GLM to see the sums of squares. The E options in the LSMESTIMATE statements above show the coefficients of the contrasts defined by the statements. You could use those coefficients in a CONTRAST statement. That is done below in GLM to show the sums of squares of the DID contrast, which is the same as the interaction, and of your contrast.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm;
class a b;
model y=a|b;
lsmeans a*b;
contrast 'avg1,2,3 v 4' a 2 -2 b 2 -2 a*b 1 1 1 -3 /e;
contrast 'did' a*b 1 -1 -1 1 /e;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Dec 2022 17:16:02 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2022-12-13T17:16:02Z</dc:date>
    <item>
      <title>contrast or lsmestimate in proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849431#M42063</link>
      <description>&lt;P&gt;hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following model&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;PROC MIXED;&lt;/DIV&gt;&lt;DIV&gt;CLASS&amp;nbsp;A B;&lt;/DIV&gt;&lt;DIV&gt;MODEL DV = A B A*B;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;A and B both have two levels, so it is a classic 2x2. There is a significant interaction, and the pattern of means shows that it is basically one of the four means that differs from the three others. Can I:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1. use contrast or&amp;nbsp;lsmestimate to test that it is indeed the case, and&lt;/DIV&gt;&lt;DIV&gt;2. that this specific contrast, which takes the form of 1 1 1 vs -3, accounts for all the variance in the interaction?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I remember learning this in graduate school, but it was 25 years ago...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you in advance.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Eman&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Dec 2022 15:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849431#M42063</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2022-12-13T15:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: contrast or lsmestimate in proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849465#M42065</link>
      <description>&lt;P&gt;Yes, you could use the CONTRAST or LSMESTIMATE statement to make that particular comparison. The LSMESTIMATE statement is easier since you don't have to determine the correct contrast coefficients. But the interaction is really the "difference in difference" (DID) as discussed in &lt;A href="http://support.sas.com/kb/61830" target="_self"&gt;this note&lt;/A&gt;. This code does both:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed;
class a b;
model y=a|b;
lsmeans a*b;
lsmestimate a*b 'avg1,2,3 v 4' 1 1 1 -3 /e;
lsmestimate a*b 'did' 1 -1 -1 1 /e;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As for question 2, it might help to use GLM to see the sums of squares. The E options in the LSMESTIMATE statements above show the coefficients of the contrasts defined by the statements. You could use those coefficients in a CONTRAST statement. That is done below in GLM to show the sums of squares of the DID contrast, which is the same as the interaction, and of your contrast.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm;
class a b;
model y=a|b;
lsmeans a*b;
contrast 'avg1,2,3 v 4' a 2 -2 b 2 -2 a*b 1 1 1 -3 /e;
contrast 'did' a*b 1 -1 -1 1 /e;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 17:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849465#M42065</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-12-13T17:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: contrast or lsmestimate in proc mixed</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849513#M42068</link>
      <description>&lt;P&gt;Thank you Dave!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 20:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/contrast-or-lsmestimate-in-proc-mixed/m-p/849513#M42068</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2022-12-13T20:50:05Z</dc:date>
    </item>
  </channel>
</rss>

