<?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 Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971356#M48803</link>
    <description>&lt;P&gt;The following code gives me the lsmeans by treatment for two of the three ordered categories in this multinomial model, slight and moderate. I understand that the probabilities conditioned on treatment for the three categories must sum to 1. However I am looking for the most concise syntax to get me the estimates &lt;STRONG&gt;with their standard errors&lt;/STRONG&gt; for all&amp;nbsp;&lt;EM&gt;k&lt;/EM&gt; categories, not just&amp;nbsp;&lt;EM&gt;k-1&amp;nbsp;&lt;/EM&gt;. I have scoured the documentation and even tried the nlmeans macro to no avail (I am not a great SAS programmer). Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ratings;
input obs blk trt rating $ y ; 
datalines;
1 1 0 slight 1 
2 1 0 moderate 4 
3 1 0 severe 23 
4 1 1 slight 2 
5 1 1 moderate 7 
6 1 1 severe 23 
7 1 2 slight 4 
8 1 2 moderate 7 
9 1 2 severe 18 
10 2 3 slight 8 
11 2 3 moderate 8 
12 2 3 severe 5 
13 2 4 slight 14 
14 2 4 moderate 14 
15 2 4 severe 7 
16 2 5 slight 14 
17 2 5 moderate 11 
18 2 5 severe 1 
19 3 0 slight 3 
20 3 0 moderate 6 
21 3 0 severe 11 
22 3 1 slight 5 
23 3 1 moderate 9 
24 3 1 severe 15 
25 3 2 slight 9 
26 3 2 moderate 5 
27 3 2 severe 11 
28 4 3 slight 11 
29 4 3 moderate 9 
30 4 3 severe 6 
31 4 4 slight 14 
32 4 4 moderate 9 
33 4 4 severe 3 
34 4 5 slight 14 
35 4 5 moderate 6 
36 4 5 severe 2 
37 5 0 slight 0 
38 5 0 moderate 6 
39 5 0 severe 13 
40 5 1 slight 4 
41 5 1 moderate 7 
42 5 1 severe 16 
43 5 2 slight 12 
44 5 2 moderate 12 
45 5 2 severe 4 
46 6 3 slight 6 
47 6 3 moderate 14 
48 6 3 severe 14 
49 6 4 slight 10 
50 6 4 moderate 13 
51 6 4 severe 8 
52 6 5 slight 16 
53 6 5 moderate 9 
54 6 5 severe 4 
55 7 0 slight 3 
56 7 0 moderate 9 
57 7 0 severe 17 
58 7 1 slight 2 
59 7 1 moderate 6 
60 7 1 severe 22 
61 7 2 slight 3 
62 7 2 moderate 10 
63 7 2 severe 9 
64 8 3 slight 8 
65 8 3 moderate 13 
66 8 3 severe 6 
67 8 4 slight 13 
68 8 4 moderate 10 
69 8 4 severe 1 
70 8 5 slight 17 
71 8 5 moderate 7 
72 8 5 severe 1 
73 9 0 slight 2 
74 9 0 moderate 3 
75 9 0 severe 23 
76 9 1 slight 1 
77 9 1 moderate 5 
78 9 1 severe 19 
79 9 2 slight 2 
80 9 2 moderate 13 
81 9 2 severe 4 
82 10 3 slight 4 
83 10 3 moderate 2 
84 10 3 severe 8 
85 10 4 slight 14 
86 10 4 moderate 5 
87 10 4 severe 11 
88 10 5 slight 12 
89 10 5 moderate 4 
90 10 5 severe 7 
;


proc glimmix data=ratings method=laplace;
  class blk trt (ref = "0");
  model rating(order=data)=trt / dist=multinomial;
  random intercept / subject=blk; 	
  freq y;
  store fit;
 run;

 proc plm restore=fit;
 	lsmeans trt / ilink cl;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jul 2025 20:32:30 GMT</pubDate>
    <dc:creator>quentinread</dc:creator>
    <dc:date>2025-07-22T20:32:30Z</dc:date>
    <item>
      <title>Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971356#M48803</link>
      <description>&lt;P&gt;The following code gives me the lsmeans by treatment for two of the three ordered categories in this multinomial model, slight and moderate. I understand that the probabilities conditioned on treatment for the three categories must sum to 1. However I am looking for the most concise syntax to get me the estimates &lt;STRONG&gt;with their standard errors&lt;/STRONG&gt; for all&amp;nbsp;&lt;EM&gt;k&lt;/EM&gt; categories, not just&amp;nbsp;&lt;EM&gt;k-1&amp;nbsp;&lt;/EM&gt;. I have scoured the documentation and even tried the nlmeans macro to no avail (I am not a great SAS programmer). Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data ratings;
input obs blk trt rating $ y ; 
datalines;
1 1 0 slight 1 
2 1 0 moderate 4 
3 1 0 severe 23 
4 1 1 slight 2 
5 1 1 moderate 7 
6 1 1 severe 23 
7 1 2 slight 4 
8 1 2 moderate 7 
9 1 2 severe 18 
10 2 3 slight 8 
11 2 3 moderate 8 
12 2 3 severe 5 
13 2 4 slight 14 
14 2 4 moderate 14 
15 2 4 severe 7 
16 2 5 slight 14 
17 2 5 moderate 11 
18 2 5 severe 1 
19 3 0 slight 3 
20 3 0 moderate 6 
21 3 0 severe 11 
22 3 1 slight 5 
23 3 1 moderate 9 
24 3 1 severe 15 
25 3 2 slight 9 
26 3 2 moderate 5 
27 3 2 severe 11 
28 4 3 slight 11 
29 4 3 moderate 9 
30 4 3 severe 6 
31 4 4 slight 14 
32 4 4 moderate 9 
33 4 4 severe 3 
34 4 5 slight 14 
35 4 5 moderate 6 
36 4 5 severe 2 
37 5 0 slight 0 
38 5 0 moderate 6 
39 5 0 severe 13 
40 5 1 slight 4 
41 5 1 moderate 7 
42 5 1 severe 16 
43 5 2 slight 12 
44 5 2 moderate 12 
45 5 2 severe 4 
46 6 3 slight 6 
47 6 3 moderate 14 
48 6 3 severe 14 
49 6 4 slight 10 
50 6 4 moderate 13 
51 6 4 severe 8 
52 6 5 slight 16 
53 6 5 moderate 9 
54 6 5 severe 4 
55 7 0 slight 3 
56 7 0 moderate 9 
57 7 0 severe 17 
58 7 1 slight 2 
59 7 1 moderate 6 
60 7 1 severe 22 
61 7 2 slight 3 
62 7 2 moderate 10 
63 7 2 severe 9 
64 8 3 slight 8 
65 8 3 moderate 13 
66 8 3 severe 6 
67 8 4 slight 13 
68 8 4 moderate 10 
69 8 4 severe 1 
70 8 5 slight 17 
71 8 5 moderate 7 
72 8 5 severe 1 
73 9 0 slight 2 
74 9 0 moderate 3 
75 9 0 severe 23 
76 9 1 slight 1 
77 9 1 moderate 5 
78 9 1 severe 19 
79 9 2 slight 2 
80 9 2 moderate 13 
81 9 2 severe 4 
82 10 3 slight 4 
83 10 3 moderate 2 
84 10 3 severe 8 
85 10 4 slight 14 
86 10 4 moderate 5 
87 10 4 severe 11 
88 10 5 slight 12 
89 10 5 moderate 4 
90 10 5 severe 7 
;


proc glimmix data=ratings method=laplace;
  class blk trt (ref = "0");
  model rating(order=data)=trt / dist=multinomial;
  random intercept / subject=blk; 	
  freq y;
  store fit;
 run;

 proc plm restore=fit;
 	lsmeans trt / ilink cl;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 20:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971356#M48803</guid>
      <dc:creator>quentinread</dc:creator>
      <dc:date>2025-07-22T20:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971357#M48804</link>
      <description>&lt;P&gt;By the way I understand that the lsmeans output for proc plm is giving me P(slight) and P(slight)+P(moderate) for each treatment. I understand that P(slight)+P(moderate)+P(severe) = 1. But what I really want is the estimate and standard error for P(slight), P(moderate), and P(severe) for each treatment and I am curious if this is easily achievable in proc plm.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 20:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971357#M48804</guid>
      <dc:creator>quentinread</dc:creator>
      <dc:date>2025-07-22T20:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971391#M48805</link>
      <description>&lt;P&gt;I have managed to calculate the standard errors by exporting the lsmeans and their covariance matrix, importing them into R, and using the delta method with the function &lt;STRONG&gt;msm::deltamethod()&lt;/STRONG&gt;. But it would still be great if I could find a way to do this in SAS!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 16:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971391#M48805</guid>
      <dc:creator>quentinread</dc:creator>
      <dc:date>2025-07-23T16:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971421#M48806</link>
      <description>&lt;P&gt;This is easily done with the current release (v3.0) of the &lt;A href="http://support.sas.com/kb/62362" target="_self"&gt;NLMeans macro&lt;/A&gt;. See the multinomial example in the Results tab of the macro documentation which helps to explain the syntax though it is applied to a nominal, not ordinal, multinomial model. For your example, the probability of SLIGHT in treatment 1 is the first mean from the LSMEANS statement, so it is referred to as &lt;EM&gt;mu1&lt;/EM&gt;&amp;nbsp; in the macro. Similarly for the remaining probabilities. So, the estimate, standard error (using the delta method), and confidence interval are provided by the following macro call after adding the E option in your LSMEANS statement and also adding this ODS statements in your PLM step:&amp;nbsp;&lt;STRONG&gt;ods output coef=coeffs;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   %nlmeans(instore=fit, coef=coeffs, link=clogit, f=mu1)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can get estimates of the treatment 1 probabilities in all three levels by subtraction using the &lt;STRONG&gt;fdata=&lt;/STRONG&gt; option and appropriate data set similar to what you see in the example in the macro documentation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data fd; 
      set=1;
      length label f $32767; 
      infile datalines delimiter=',';
      input label f; 
      datalines;
   P(slight trt1),   mu1 
   P(moderate trt1),  mu7-mu1
   P(severe trt1),  1-mu7
   ;
   %nlmeans(instore=fit, coef=coeffs, link=clogit, fdata=fd)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jul 2025 03:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971421#M48806</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2025-07-24T03:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc plm lsmeans give me all k categories in glimmix multinomial, not k-1 categories?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971432#M48807</link>
      <description>&lt;P&gt;Thank you this is extremely helpful! Just one thing I noticed. The parameter df must be explicitly provided, to get the same confidence intervals as the original lsmeans. According to the documentation, if df is omitted, NLMEANS will use large-sample Wald statistics. In this example it hardly makes any difference because df=768, but I wanted to point that out for future reference.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 13:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Can-proc-plm-lsmeans-give-me-all-k-categories-in-glimmix/m-p/971432#M48807</guid>
      <dc:creator>quentinread</dc:creator>
      <dc:date>2025-07-24T13:22:33Z</dc:date>
    </item>
  </channel>
</rss>

