<?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: How do I visualize fitted values from a mixed-effects model in GLIMMIX? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/293994#M15635</link>
    <description>&lt;P&gt;You can use the OUTPUT statement to compute the predicted values on the inverse link scale. &amp;nbsp;You can create the predicted values accounting for the random effect, but probably you are asking for the marginal predicted values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a binomial response, the observed values are proportions. You can compute that quantity in PROC LMIMIX itself, or in a separate DATA Step. In the following, I compute in in the PROC, then use PROC SGPLOT to overlay a scatter plot of the data and a curve for the predicted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
input Site Success Trials Explanatory;
datalines;
 1 20 30 10
 2 10 18  8
 3 15 30  5
 4 20 55  5
 5  5 60  3
11 20 28  9
12 11 16  8
13 14 25  6
14 18 45  4
15  7 54  2
;

proc glimmix data= data1;
class Site;
model Success/Trials = Explanatory /solution link=logit err=binomial;
random Site;
proportion = Success / Trials;   /* create new variable for graphing */
output out=PredOut predicted(noblup ilink)=PredMarg /* marginal mean */
         / symbols;              /* write proportion variable to output data */
run;

proc sort data=PredOut;
by Explanatory;
run;

proc sgplot data=PredOut;
scatter x=Explanatory y=proportion / datalabel=Site; 
series x=Explanatory y=PredMarg;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Aug 2016 12:26:40 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-08-25T12:26:40Z</dc:date>
    <item>
      <title>How do I visualize fitted values from a mixed-effects model in GLIMMIX?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/293949#M15631</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a logistic mixed-effects model, I am trying to visualize the fitted response on top of the original data points. What confuses me is that the fitted curve seems to run much too low as compared to the (eye-balled) mean of the data points. Could anybody advice me on why this may be happening (or simply point out what I am misunderstanding)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax is very simple (as implemnted in v.9.4):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc glimmix data= data1;&lt;/P&gt;&lt;P&gt;class Site;&lt;/P&gt;&lt;P&gt;model Success/Trials = Explanatory /solution link=logit err=binomial;&lt;/P&gt;&lt;P&gt;random Site;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then extract the intercept (a) and coefficient (b) from solutions and plot the fitted curve at the original (ilink) scale as&lt;/P&gt;&lt;P&gt;y=exp(a+b*Explanatory)/(1+(a+b*Explanatory))&lt;/P&gt;&lt;P&gt;Here, I expect the resultant prediction y to apply to the mean value of the random effect, and hence to – on average – hit the middle of the original data points (expressed as the ratio Success/Trials). But as said, when visually examined, the fitted function seems to run much too low at the ilink scale.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am now wondering whether I am misunderstanding something basic about the default parameterization of the random effect in glimmix? Or is there some other reason why this should not work as outlined above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I am completely off the mark then how would you create the plot described above, with the idea of showing the original data and the fitted function at the original scale, for immediate and intuitive interpretation by the non-expert viewer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With very many thanks for any advice you may offer,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 06:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/293949#M15631</guid>
      <dc:creator>TVR</dc:creator>
      <dc:date>2016-08-25T06:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I visualize fitted values from a mixed-effects model in GLIMMIX?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/293994#M15635</link>
      <description>&lt;P&gt;You can use the OUTPUT statement to compute the predicted values on the inverse link scale. &amp;nbsp;You can create the predicted values accounting for the random effect, but probably you are asking for the marginal predicted values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a binomial response, the observed values are proportions. You can compute that quantity in PROC LMIMIX itself, or in a separate DATA Step. In the following, I compute in in the PROC, then use PROC SGPLOT to overlay a scatter plot of the data and a curve for the predicted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
input Site Success Trials Explanatory;
datalines;
 1 20 30 10
 2 10 18  8
 3 15 30  5
 4 20 55  5
 5  5 60  3
11 20 28  9
12 11 16  8
13 14 25  6
14 18 45  4
15  7 54  2
;

proc glimmix data= data1;
class Site;
model Success/Trials = Explanatory /solution link=logit err=binomial;
random Site;
proportion = Success / Trials;   /* create new variable for graphing */
output out=PredOut predicted(noblup ilink)=PredMarg /* marginal mean */
         / symbols;              /* write proportion variable to output data */
run;

proc sort data=PredOut;
by Explanatory;
run;

proc sgplot data=PredOut;
scatter x=Explanatory y=proportion / datalabel=Site; 
series x=Explanatory y=PredMarg;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 12:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/293994#M15635</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-25T12:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I visualize fitted values from a mixed-effects model in GLIMMIX?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294102#M15643</link>
      <description>&lt;P&gt;Adding to Rick's valuable response, note that the marginal predicted value corresponds to predicted linear predictor (.e.g, logit) where the random effects are at their theoretical average value (=0). The inverse-link of this predicted value is &lt;STRONG&gt;not&lt;/STRONG&gt; the predicted probability averaged over the random effects. This is because the inverse link is a non-linear function.&amp;nbsp; The inverse-link does correspond to the predicted probability when the random effects take the value of 0. Thus, the predicted p from the inverse-link function is not the mean of the proportions over the sites.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read SAS Global Forum articles by Walt Stroup or his excellent 2015 article in Agronomy Journal (open access) for details on this.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 17:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294102#M15643</guid>
      <dc:creator>lvm</dc:creator>
      <dc:date>2016-08-25T17:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I visualize fitted values from a mixed-effects model in GLIMMIX?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294103#M15644</link>
      <description>&lt;P&gt;If you want to investigate the alternative that LVM mentions, you can get the predictions&amp;nbsp;that&amp;nbsp;include the random effects with&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;predicted&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;ilink&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;Pred&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, you won't get a nice smooth curve in the fit plot.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 17:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294103#M15644</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-25T17:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I visualize fitted values from a mixed-effects model in GLIMMIX?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294380#M15672</link>
      <description>&lt;P&gt;Very many thanks for your quick and valuable pointers!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 13:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-visualize-fitted-values-from-a-mixed-effects-model-in/m-p/294380#M15672</guid>
      <dc:creator>TVR</dc:creator>
      <dc:date>2016-08-26T13:32:30Z</dc:date>
    </item>
  </channel>
</rss>

