<?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 to plot regression line from mixed models in my observed values? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/424713#M22336</link>
    <description>&lt;P&gt;The predicted values produced by PROC MIXED are for the values of the categorical and continuous predictors present in the data.&amp;nbsp; You cannot change the values used to create the prediction - that really would not make a lot of sense.&amp;nbsp; The prediction for an observation in the input data set should be for the data in that observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get MIXED to give you extra predictions, though.&amp;nbsp; You can add observations to the DATA= data set that are at levels of the predictors that are of interest to you.&amp;nbsp; Set the value of the response value to missing.&amp;nbsp; Since the response is missing, MIXED will not use the information in those observations when estimating the parameters.&amp;nbsp; If only the response is missing, MIXED will produce predicted values and confidence intervals for those predictions.&amp;nbsp; You can use those predictions to create the plot you want using SGPLOT.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2018 19:49:16 GMT</pubDate>
    <dc:creator>StatsMan</dc:creator>
    <dc:date>2018-01-03T19:49:16Z</dc:date>
    <item>
      <title>How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/393750#M20565</link>
      <description>&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;&lt;SPAN&gt;Hello SAS Community!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;&lt;SPAN&gt;So I am new to SAS, using SAS University edition (and not the most statistically savvy person). I have ran done mixed regression models using the Proc Mixed command while blocking on participants to control for repeated observations. Just an example of a code I used for one model:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;proc mixed data=mito method=ml;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;class mrn sex ;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;model respiration=age sex time / s outp=pred_resp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;random intercept / subject=mrn type=VC;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;run;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;&lt;SPAN&gt;So basically then I plot the fitted line from the mixed model in the Observed values but the only thing I managed to do yet is get a graph of predicted and absolute values (in one or separate graphs) but the line is not really the line from the equation I get from model applied above:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;proc sgplot data=pred_resp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;reg x=age y=respiration / clm;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;reg x=age&amp;nbsp;y=pred / clm;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;YAXIS GRID VALUES = (0 TO 100 BY 20);&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;run;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;FONT color="#1F497D"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;I just wanted to plot the fitted line in the observed values (original data) and also add the confidence limits and prediction intervals. Have lost days looking for this!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;Thank you all!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2" face="Calibri,sans-serif"&gt;&lt;SPAN style="font-size: 11pt;"&gt;Vic&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 03:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/393750#M20565</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-09-07T03:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/393974#M20566</link>
      <description>&lt;P&gt;Post your data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think there are some issue with what you describe. You say you have repeated measurement (time), but it is not clear how you want to handle that. Do you want to plot at a particular time such as t=0?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some general suggestions:&lt;/P&gt;
&lt;P&gt;1. Consider whether you should use the OUTPM= option to output the mean value, not the individual predictions.&lt;/P&gt;
&lt;P&gt;2. Use the BAND statement to plot the lower and upper limits (possibly use GROUP=SEX)&lt;/P&gt;
&lt;P&gt;3. Use the SERIES statement to draw the predicted curves&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;(possibly use GROUP=SEX)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4.&amp;nbsp;&lt;/SPAN&gt;Use the SCATTER statement to plot the raw data &lt;SPAN&gt;&amp;nbsp;(possibly use GROUP=SEX)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some simulated data that are modeled by IGNORING (averaging over) the time variable. Maybe you or someone else can modify this approach when&amp;nbsp;you tell us how to handle&amp;nbsp;time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA MITO;
call streaminit(1);
input mrn age sex $;
do time = 0 to 5;
   respiration = 50 + 2*(sex='F') + 0.05*age + 0.1*time + rand("normal");
   output;
end;
datalines;
1 18 F
2 26 F
3 19 M
4 25 M
5 22 F
6 30 M
;
run;

proc mixed data=mito method=ml;
class mrn sex;
model respiration=age sex /*time*/ / s outpm=pred_resp;
random intercept / subject=mrn type=VC;
run;

proc sort data=pred_resp; by age; run;

proc sgplot data=pred_resp; 
band x=age lower=Lower upper=Upper / group=sex;
series x=age y=pred / group=sex;
scatter x=age  y=respiration / group=sex;
YAXIS GRID;
run;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2017 17:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/393974#M20566</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-09-07T17:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394071#M20575</link>
      <description>&lt;P&gt;Hello Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for the fast response and for helping me out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies for not posting the data but it has not been published yet. However, I can publish some data that is not for publishing to use as an example if it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Time in my model is a continuous variable so there are no fixed timepoints. This&amp;nbsp;is clinical data from hospitalized patients and measurements differ by time collected so we need to adjust for time of measurement and hence, include time in the models. It is basically the time from&amp;nbsp;hospital admission to actual measurement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran your script and when group=sex is in, it looks good, but when I remove it from the sgplot then I get a curved line rather than a straight line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The plot I am trying to re-create looks like this (below), where values are the observed ones and line of best fit is the one from the prediction equation obtained form the mixed regression model:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Layout 1.jpg" style="width: 456px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14910iE9598EA99D7FEE27/image-dimensions/456x518?v=v2" width="456" height="518" role="button" title="Layout 1.jpg" alt="Layout 1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, can you please let me know what is the difference between OUTP and OUTPM? I used both and the pred column&amp;nbsp;in the output dataset is per individual in both cases so cannot see where they differ. Also, I ran the script you sent with the pred from OUTP and OUTPM and is the same. I am really new to SAS so still trying to figure basic stuff out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a ton!&lt;/P&gt;&lt;P&gt;Vic&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 22:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394071#M20575</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-09-07T22:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394172#M20577</link>
      <description>&lt;P&gt;The graph you show is typical for a fixed-effect model of response&amp;nbsp;vs time. &amp;nbsp;In your model, you have additional covariates, so you need to specify how to handle them in a 2D plot. &amp;nbsp;Technically, you are fitting many curves,&amp;nbsp;one for each subject, so it is not clear how you want to condense that information into one line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, do you want to show the model for the mean value of the age? The median? Do you want two curves for each value of the sex variable or do you want separate&amp;nbsp;graphs for male/female? These are all questions to consider in a model that has three covariates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 09:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394172#M20577</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-09-08T09:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394268#M20578</link>
      <description>&lt;P&gt;I see, thank you Rick!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I meant to plot it by using the mean value for all the covariates not represented in the graph. I might need to add the group function too. In my current model I actually have more predictors as last night I added one more. But I guess since I just take the means of the factors not represented in y x axes it does not matter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 16:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394268#M20578</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-09-08T16:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394734#M20613</link>
      <description>&lt;P&gt;Sorry for the number of messages&amp;nbsp;- so is there a way to&amp;nbsp;achieve this type of graph?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Vic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 16:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/394734#M20613</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-09-11T16:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/418958#M22018</link>
      <description>&lt;P&gt;I am trying to do the same thing. I have a generalized linear mixed model with several covariates that I have modeled in glimmix:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc glimmix;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glimmix;
 class horse trainer;
 model freq_PMN/TNCC= trainer resp age inhale ups glucan resp*lps ;
 random int/ subject=horse type=ar(1);
 random _residual_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am interested in plotting the predicted and 95% CI for freq_PMN/TNCC versus resp at the mean levels of the other covariates and overlaying the observed values. Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/418958#M22018</guid>
      <dc:creator>kivester</dc:creator>
      <dc:date>2017-12-06T20:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/418960#M22019</link>
      <description>&lt;P&gt;Hey Kivester,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I never found out how to do this in SAS...so a colleague just did it for me in R. I bet there is a way to do this in SAS too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I even asked a statistician at my institution that uses SAS a lot and works in epidemiology, but told me she has never done this before because they usually just present the beta coefficients and they do not need to present a plot of this. However, I was submitting a paper in a clinical journal and clinicians appear to like plots so had to find a way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/418960#M22019</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-12-06T21:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419021#M22023</link>
      <description>&lt;P&gt;If you post some sample data (it can be made up), then we could make suggestions. I proposed some sample data and said&amp;nbsp;to the OP, "&lt;SPAN&gt;Maybe you ...can modify this approach [and] tell us how to handle&amp;nbsp;time." The OP never addressed that question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146465"&gt;@papagalini&lt;/a&gt;&amp;nbsp;Since you claim that you were able to produce the graph you want in other software, please post the graph so that we can understand what you are looking for.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 00:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419021#M22023</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-07T00:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419025#M22026</link>
      <description>&lt;P&gt;Rick,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some made up data. Thanks for agreeing to help!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data MadeUP;
Input  horse Freq_PMN TNCC trainer resp age inhal lps glucan;
datalines;
1	6	300	8	0.35	4.2	0.34	1.4	53.1
2	4	112	8	0.064	4.416	1.492	9.143	256.411
3	20	189	4	0.191	0.137	3.105	5.427	262.197
4	17	291	4	0.124	4.188	3.126	4.923	208.315
5	18	385	1	0.058	2.956	3.289	0.945	254.197
5	0	123	1	0.025	0.464	1.784	7.311	283.147
7	7	226	2	0.175	3.965	0.668	6.183	186.320
8	17	15	4	0.171	1.774	3.091	4.858	121.950
8	17	320	4	0.148	1.699	1.088	9.965	257.282
8	2	1	4	0.129	2.507	1.012	7.521	322.331
8	17	56	4	0.179	2.538	1.924	0.651	110.123
9	15	113	3	0.110	4.037	2.661	0.585	333.831
10	3	44	1	0.182	4.877	0.077	5.208	292.303
14	20	299	7	0.177	2.238	2.490	7.207	327.078
15	17	246	1	0.043	0.581	0.930	6.753	64.075
15	7	78	1	0.013	3.826	0.622	5.364	311.640
15	9	285	1	0.032	2.302	3.636	5.400	107.441
18	8	152	5	0.016	2.722	1.801	7.350	341.055
19	14	392	5	0.160	0.737	0.999	5.862	314.837
20	10	398	7	0.112	2.973	3.691	7.995	322.038
20	20	328	7	0.039	2.221	3.991	9.583	163.122
21	13	206	4	0.148	1.245	3.986	0.648	322.854
22	17	187	2	0.197	0.926	1.096	3.555	130.459
23	20	253	1	0.171	2.663	3.850	8.469	114.644
24	11	97	1	0.086	2.594	1.739	0.959	310.298
25	16	83	4	0.072	3.385	3.934	6.602	198.959
26	14	248	8	0.002	0.546	1.020	8.069	66.514
26	14	364	8	0.027	3.378	1.559	9.159	292.377
26	14	26	8	0.107	1.262	0.825	6.589	135.586
29	3	119	1	0.169	0.517	3.756	2.659	303.409
30	9	74	1	0.059	4.357	1.232	5.881	83.229
31	6	280	1	0.035	3.508	2.747	9.789	10.971
33	6	251	1	0.118	2.325	3.156	3.601	306.553
;
proc glimmix;
 class horse trainer;
 model freq_PMN/TNCC= trainer resp age inhal lps glucan resp*lps;
random int/ subject=horse type=ar(1);
random _residual_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 01:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419025#M22026</guid>
      <dc:creator>kivester</dc:creator>
      <dc:date>2017-12-07T01:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419080#M22030</link>
      <description>&lt;P&gt;Hello Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response. I have attached the graph that my colleague produced in other software.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 06:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419080#M22030</guid>
      <dc:creator>papagalini</dc:creator>
      <dc:date>2017-12-07T06:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419128#M22032</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139049"&gt;@kivester&lt;/a&gt;&amp;nbsp;There is no "mean level" for the Trainer variable. For categorical variables, you can specify&amp;nbsp;a reference value on the CLASS statement and then use that reference level for the summary plot. For example, you can say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;CLASS horse trainer(ref='1');&lt;/P&gt;
&lt;P&gt;to use Trainer=1 as the reference level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 11:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419128#M22032</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-07T11:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419175#M22033</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, that makes sense. Is there a way to&amp;nbsp;specify that the predicted values in the output are for trainer 1 and the mean values of the covariates? I realize the fit won't be very impressive, but this type of graph has been requested by my co-authors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help!&lt;/P&gt;&lt;P&gt;Katy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 14:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419175#M22033</guid>
      <dc:creator>kivester</dc:creator>
      <dc:date>2017-12-07T14:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419258#M22038</link>
      <description>&lt;P&gt;Before diving into graphics for predicted values, you'll want to identify a correct model that works for your data. I have some concerns about both data and model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your actual dataset have more than 24 horses and 33 observations? Your model is trying to estimate 13 fixed effects parameters, and&amp;nbsp;you would need a lot more data&amp;nbsp;for the model to do that well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the MadeUp dataset, there are two observations with Freq_PMN &amp;gt; TNCC. These observations are rejected by the binomial distribution because Freq_PMN must be &amp;lt;= TNCC. Is this a problem that appears in your actual dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The model is regressing Freq_PMN/TNCC on resp (plus the other continuous predictors). Are you content to fit a&amp;nbsp;random intercepts model and consequently to assume that the slopes of the regressions do not vary by horse (i.e., to not incorporate random slopes)? In the MadeUp dataset, only 5 of the 24 horses have&amp;nbsp;multiple measures, ranging from n= 2 to 4, which is not enough information to fit random slopes. If the actual dataset has little by way of repeated measures on horses, then random slopes is a moot point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt that your RANDOM statements are actually doing what you intended them to do. The best resource for this topic is Walt Stroup's text&lt;/P&gt;
&lt;P&gt;&lt;A title="Generalized Linear Mixed Models: Modern Concepts, Methods and Applications" href="https://www.crcpress.com/Generalized-Linear-Mixed-Models-Modern-Concepts-Methods-and-Applications/Stroup/p/book/9781439815120" target="_self"&gt;https://www.crcpress.com/Generalized-Linear-Mixed-Models-Modern-Concepts-Methods-and-Applications/Stroup/p/book/9781439815120&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to acquire predicted values for graphing is to score a new data set using the PLM procedure. See&lt;/P&gt;
&lt;P&gt;&lt;A title="Introducing PROC PLM and Postfitting Analysis for Very General Linear Models in SAS/STAT® 9.22" href="https://support.sas.com/resources/papers/proceedings10/258-2010.pdf" target="_self"&gt;https://support.sas.com/resources/papers/proceedings10/258-2010.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;A title="Usage Note 33307: Scoring (computing predicted values) for new observations or a validation data set" href="http://support.sas.com/kb/33/307.html" target="_self"&gt;http://support.sas.com/kb/33/307.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;A title="Advanced Techniques for Fitting Mixed Models Using SAS/STAT® Software" href="https://support.sas.com/resources/papers/proceedings15/SAS1919-2015.pdf" target="_self"&gt;https://support.sas.com/resources/papers/proceedings15/SAS1919-2015.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Pay attention to the information about scoring a mixed model in this last link.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps some.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 17:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419258#M22038</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-12-07T17:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419448#M22055</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1708"&gt;@sld&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your help. I haven't read all of the links that you have provided yet, but to answer some of your questions, my actual dataset has 67 observations. Yes, I have some subjects that I have only one observation for, and others that I have 2 or 3 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The instances of PMN&amp;gt;TNCC is an accident of the random data I used. This does not occur in my data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I am happy to fit a random intercept model. I have included the random _residual_ statement due to apparent over dispersion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Katy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419448#M22055</guid>
      <dc:creator>kivester</dc:creator>
      <dc:date>2017-12-08T02:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419452#M22056</link>
      <description>&lt;P&gt;Hi Katy,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the update.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are rules of thumb for the ratio of number of observations to number of estimated parameters that range from 10:1 to 30:1, or more or less. (It's a "rule of thumb", so that's what we can expect.) Regardless, with only 67 observations spread over an unknown but smaller number of horses, your current model is attempting too much (i.e., it is overfitted). I suggest that you try to find a more parsimonious model with fewer predictor variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do want to assess whether data may be overdispersed with respect to the binomial distribution. But first you should consider your other RANDOM statement:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;random int/ subject=horse type=ar(1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This statement specifies that horses are not independent--it specifies that horses are correlated according to an AR(1) structure, which makes no sense to me. What are you attempting to do with this RANDOM statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/419452#M22056</guid>
      <dc:creator>sld</dc:creator>
      <dc:date>2017-12-08T02:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/424713#M22336</link>
      <description>&lt;P&gt;The predicted values produced by PROC MIXED are for the values of the categorical and continuous predictors present in the data.&amp;nbsp; You cannot change the values used to create the prediction - that really would not make a lot of sense.&amp;nbsp; The prediction for an observation in the input data set should be for the data in that observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get MIXED to give you extra predictions, though.&amp;nbsp; You can add observations to the DATA= data set that are at levels of the predictors that are of interest to you.&amp;nbsp; Set the value of the response value to missing.&amp;nbsp; Since the response is missing, MIXED will not use the information in those observations when estimating the parameters.&amp;nbsp; If only the response is missing, MIXED will produce predicted values and confidence intervals for those predictions.&amp;nbsp; You can use those predictions to create the plot you want using SGPLOT.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 19:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/424713#M22336</guid>
      <dc:creator>StatsMan</dc:creator>
      <dc:date>2018-01-03T19:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to plot regression line from mixed models in my observed values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/424742#M22337</link>
      <description>&lt;P&gt;In short,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/92458"&gt;@StatsMan&lt;/a&gt;'s suggestion is equivalent to &lt;A href="https://blogs.sas.com/content/iml/2017/12/20/create-sliced-fit-plot-sas.html" target="_self"&gt;creating a sliced fit plot&lt;/A&gt;. Many SAS regression procedures support the STORE statement to store the model in a SAS item store. You can then use PROC PLM to create the plot, as shown in the linked article.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The article also shows how to create a sliced fit plot when you want to include the observations or when you are using a procedure that does not support the STORE statement. What you do is to&amp;nbsp;create a data set that contains the "slice" you want to score on. As StatsMan says, you use missing values for the response. Then you score the data and create the plot of the predicted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/12/20/create-sliced-fit-plot-sas.html" target="_self"&gt;How to create a sliced fit plot in SAS&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 20:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-plot-regression-line-from-mixed-models-in-my-observed/m-p/424742#M22337</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-01-03T20:47:12Z</dc:date>
    </item>
  </channel>
</rss>

