<?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: Estimating predicted probability  using Proc Glimmix for set parameters in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/387489#M20183</link>
    <description>&lt;P&gt;I just tried to get at the predicted means using the output statement, but it doesn't appear to&amp;nbsp;take into account the "estimate" statements I added in. &amp;nbsp;Is there a way to do this? &amp;nbsp;Or do I need to somehow create an output statement for each attending using a where statement to get at the predicted means for each attending?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro doEst;
%do i=1 %to 34;
estimate "Attending &amp;amp;i" int 1 age18_34 1 gender_m 1 | int 1 / subject %do k=1 %to %eval(&amp;amp;i-1); 0 %end; 1 ilink e;
%end;
%mend;

proc glimmix data=tables method=quad(qpoints=31) noclprint;
class attending;
model contact (descending) = age18_34 age35_54 gender_m 

/CL DIST=Binary link=logit solution;

random intercept /  subject=attending S CL Type=VC ;

COVTEST / wald;

output out=glm_out pred(ilink) lcl(ilink) ucl(ilink) stderr(ilink);

%doest;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Aug 2017 20:41:05 GMT</pubDate>
    <dc:creator>einstein</dc:creator>
    <dc:date>2017-08-11T20:41:05Z</dc:date>
    <item>
      <title>Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374528#M19618</link>
      <description>&lt;P&gt;Hello, I'm new at this, so not sure if I'm explaining this correctly, but I'm trying to estimate predicted probably of a doctor having enough interaction with a patient based on predictors having a set value. &amp;nbsp;So probabilty Doctor 1, Doctor 2, Doctor 3, etc &amp;nbsp;has enough interaction with the patient if the patient is age 18-34, female, with a college degree&amp;nbsp;or higher. &amp;nbsp;I tried using this code below using "estimate", but it doesn't seem to be working. &amp;nbsp;Anyone know what I might be doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc glimmix data=tables2 method=laplace noclprint;
class attending;
model doc_interaction (descending) = age18_34 age35_54 gender_m edu_hs_m edu_some_m edu_col_M
/CL DIST=Binary link=logit solution;
estimate "Intercept Age 18-34, female, college grad or higher" 
int 1 age18_34 1 gender_m 1 edu_col_m 1 / ILINK; 
random intercept /  subject=attending S CL Type=VC ;
COVTEST / wald;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 14:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374528#M19618</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-07-10T14:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374644#M19629</link>
      <description>&lt;P&gt;Are you getting an error or warning message from the GLIMMIX procedure? &amp;nbsp;The simulation below does something similar to your model, with the addition of some fixed effects. &amp;nbsp;The MEAN column in the ESTIMATE statement output gives you the predicted probability for the variables you have specified (and averaged over any additional fixed effects in the model).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt; call streaminit(6354153); /* initialize random number stream */&lt;BR /&gt; do a=1 to 10; /* 10 levels to the random effect */&lt;BR /&gt; ra=rand('normal',.7); /* generate random intercept adjustment for each level */&lt;BR /&gt; do i=1 to 20;&lt;BR /&gt; x1=rand('uniform'); /* generate random covariates */&lt;BR /&gt; x2=rand('uniform');&lt;BR /&gt; x3=rand('normal')*.5;&lt;BR /&gt; x4=rand('normal')*.5;&lt;BR /&gt; trt=ceil(rand('uniform')*3); /* generate trt and group levels */&lt;BR /&gt; grp=ceil(rand('uniform')*5);&lt;BR /&gt; &lt;BR /&gt; logit=-2 + 2*x1 + x2 + x3 - x4 + (trt-2) + (grp-3) + ra; /* calculate the logit */&lt;BR /&gt; p=exp(-logit)/(1+exp(-logit)); /* and then the predicted probability */&lt;BR /&gt; if rand('uniform')&amp;gt;p then y=1; else y=0; /* assign the response */&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc glimmix data=test method=laplace;&lt;BR /&gt; class a trt grp;&lt;BR /&gt; model y=trt grp x1 x2 x3 x4 / s dist=bin link=logit;&lt;BR /&gt; random intercept / subject=a;&lt;BR /&gt; estimate '1' int 1 x1 1 x2 1 / ilink e;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 18:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374644#M19629</guid>
      <dc:creator>StatsMan</dc:creator>
      <dc:date>2017-07-10T18:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374653#M19630</link>
      <description>&lt;P&gt;Nope, I don't get an error. &amp;nbsp;It seems to run fine, but I'm not getting the output I expect. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to get at an estimate for each physician ("attending" in my dataset) as opposed to just one estimate in the&amp;nbsp;&lt;SPAN&gt;ESTIMATE statement output, so that I can get at a predicted probability for each physician for the variables I have specified&lt;/SPAN&gt;? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 18:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374653#M19630</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-07-10T18:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374664#M19632</link>
      <description>&lt;P&gt;You will need one ESTIMATE statement for each attending you have in your data. &amp;nbsp;For the second level of attending, the ESTIMATE statement might look something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;estimate '2' int 1 x1 1 x2 1 | int 1 / subject 0 1 ilink e;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You include the random effects you need in your ESTIMATE statement after the | operator (the vertical bar operator). &amp;nbsp;Since we also have a SUBJECT= effect in the RANDOM statement, you specify the subject of interest for the RANDOM statement with the SUBJECT option. &amp;nbsp;Treat this effect like you would any other CLASS effect in your model.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you have a lot of levels to the attending effect, this could get rather tedious. &amp;nbsp;You will need one ESTIMATE statement for each of those levels. &amp;nbsp;However, SAS Macro code can make writing all of these ESTIMATE statements a snap. &amp;nbsp;Try something like&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%do i=1 %to 10;&lt;BR /&gt;estimate "&amp;amp;i" int 1 x1 1 x2 1| int 1 / subject %do k=1 %to %eval(&amp;amp;i-1); 0 %end; 1 ilink e;&lt;BR /&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That macro loop will generate the estimates you need for the first ten attending levels. &amp;nbsp;Just change the 10 on that %do line to generate more ESTIMATE statements. &amp;nbsp;You will need to put your PROC GLIMMIX in a macro to make this work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have ammended the code below to include this suggestion and to include Rick's suggestion just below my answer.&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt; call streaminit(6354153); /* initialize random number stream */&lt;BR /&gt; do a=1 to 10; /* 10 levels to the random effect */&lt;BR /&gt; ra=rand('normal',.7); /* generate random intercept adjustment for each level */&lt;BR /&gt; do i=1 to 20;&lt;BR /&gt; x1=rand('uniform'); /* generate random covariates */&lt;BR /&gt; x2=rand('uniform');&lt;BR /&gt; x3=rand('normal')*.5;&lt;BR /&gt; x4=rand('normal')*.5;&lt;BR /&gt; trt=ceil(rand('uniform')*3); /* generate trt and group levels */&lt;BR /&gt; grp=ceil(rand('uniform')*5);&lt;BR /&gt; &lt;BR /&gt; logit=-2 + 2*x1 + x2 + x3 - x4 + (trt-2) + (grp-3) + ra; /* calculate the logit */&lt;BR /&gt; p=exp(-logit)/(1+exp(-logit)); /* and then the predicted probability */&lt;BR /&gt; if rand('uniform')&amp;gt;p then y=1; else y=0; /* assign the response */&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc glimmix data=test method=laplace;&lt;BR /&gt; class a trt grp;&lt;BR /&gt; model y=trt grp x1 x2 x3 x4 / s dist=bin link=logit;&lt;BR /&gt; random intercept / subject=a;&lt;BR /&gt; estimate '1' int 1 x1 1 x2 1 | int 1 / subject 1 ilink e;&lt;BR /&gt; estimate '2' int 1 x1 1 x2 1 | int 1 / subject 0 1 ilink e; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro doests;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%do i=1 %to 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;estimate "&amp;amp;i" int 1 x1 1 x2 1| int 1 / subject %do k=1 %to %eval(&amp;amp;i-1); 0 %end; 1 ilink e;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc glimmix data=test method=laplace;&lt;BR /&gt; class a trt grp;&lt;BR /&gt; model y=trt grp x1 x2 x3 x4 / s dist=bin link=logit;&lt;BR /&gt; random intercept / subject=a;&lt;BR /&gt; %doests;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 11:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374664#M19632</guid>
      <dc:creator>StatsMan</dc:creator>
      <dc:date>2017-07-11T11:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374669#M19633</link>
      <description>&lt;P&gt;Oh my goodness - it worked! &amp;nbsp;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 19:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374669#M19633</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-07-10T19:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374736#M19639</link>
      <description>&lt;P&gt;Great answer by StatsMan. I'll merely add that you don't need the whole GLIMMIX call in a macro, only the ESTIMATE statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doEst;
%do i=1 %to 10;
 estimate "&amp;amp;i" int 1 x1 1 x2 1| int 1 / subject %do k=1 %to %eval(&amp;amp;i-1); 0 %end; 1 ilink e;
%end;
%mend;

proc glimmix data=test method=laplace;
 class a trt grp;
 model y=trt grp x1 x2 x3 x4 / s dist=bin link=logit;
 random intercept / subject=a;
%doEst;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2017 22:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/374736#M19639</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-10T22:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375054#M19660</link>
      <description>&lt;P&gt;Just tried this and it worked great! &amp;nbsp;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I also just noticed that the&amp;nbsp;&lt;SPAN&gt;labels of the providers don't actually match the attending codes I have. &amp;nbsp;Is there a way to fix this? &amp;nbsp;So my Labels are Attending 1, Attending 2, etc. but the attending codes I have starts with 2 and skips around. &amp;nbsp;Its starting to get confusing.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, is there a way to see the confidence intervals without me having to manually calculate them in the estimates section? &amp;nbsp;Is there an option for that?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 17:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375054#M19660</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-07-11T17:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375095#M19662</link>
      <description>&lt;P&gt;The CL option on the ESTIMATE statement does not provide a confidence interval on the inverse link scale. &amp;nbsp;You would have to manually calculate that result, and those confidence bands tend to be pretty wide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you talking about the labels that are written to the ESTIMATE statement results themselves? &amp;nbsp;Using the macro code, yes, that just gives the numbers 1,2,3, etc. to the estimates in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ordering of the subjects is either given in the output of the CLASS levels table (if the SUBJECT= effect is a CLASS variable) or is the order the subjects appear in your input data set if the SUBJECT= effect does not appear on the CLASS statement. &amp;nbsp;You can create a SAS data set that has the ordered subject levels in either scenario and create macro variables from this set of subject values. &amp;nbsp;The macro variables can then be used in the label for the ESTIMATE statements. &amp;nbsp;I do not have code handy for this task, however. &amp;nbsp;Perhaps someone else has that available?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 19:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375095#M19662</guid>
      <dc:creator>StatsMan</dc:creator>
      <dc:date>2017-07-11T19:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375115#M19664</link>
      <description>Thanks for the reply. I guess I'll just have to live with manually&lt;BR /&gt;calculating the CIs and the labels that are written to the estimate&lt;BR /&gt;statement. Thanks again for all your help!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 11 Jul 2017 20:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/375115#M19664</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-07-11T20:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating predicted probability  using Proc Glimmix for set parameters</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/387489#M20183</link>
      <description>&lt;P&gt;I just tried to get at the predicted means using the output statement, but it doesn't appear to&amp;nbsp;take into account the "estimate" statements I added in. &amp;nbsp;Is there a way to do this? &amp;nbsp;Or do I need to somehow create an output statement for each attending using a where statement to get at the predicted means for each attending?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro doEst;
%do i=1 %to 34;
estimate "Attending &amp;amp;i" int 1 age18_34 1 gender_m 1 | int 1 / subject %do k=1 %to %eval(&amp;amp;i-1); 0 %end; 1 ilink e;
%end;
%mend;

proc glimmix data=tables method=quad(qpoints=31) noclprint;
class attending;
model contact (descending) = age18_34 age35_54 gender_m 

/CL DIST=Binary link=logit solution;

random intercept /  subject=attending S CL Type=VC ;

COVTEST / wald;

output out=glm_out pred(ilink) lcl(ilink) ucl(ilink) stderr(ilink);

%doest;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 20:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Estimating-predicted-probability-using-Proc-Glimmix-for-set/m-p/387489#M20183</guid>
      <dc:creator>einstein</dc:creator>
      <dc:date>2017-08-11T20:41:05Z</dc:date>
    </item>
  </channel>
</rss>

