Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How to test equality of three mean expressions coming from PROC MIXED ...

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 10-13-2023 02:27 PM
(217 views)

I'm analyzing data using an MMRM with PROC MIXED. The covariates are treatment (i=1,2,3,4), visit (j=1,2,3,4,5), and age group (k=1,2,3) with three-way and all two-way interactions included, along with 3 other covariates. I'm mainly using ESTIMATE statements to provide treatment differences at visit 4, very simple. I have one hypothesis I want to test that is more complicated, and I can't figure out if I can use built-in SAS statements.

I want to test if the difference between treatment 1 and 2 is the same across the 3 age groups at week 24. So, using the (ijk) notation...

H_0 = mu_(141)-mu_(241) = mu(142)-mu_(242) = mu_(143)-mu_(243)

H_a = not all equal

It would be simple to test the equality of any two of these expressions using ESTIMATE statements, but there are three expressions here I guess necessitating an ANOVA kind of test? I'm not sure how to go about coding this test. Main modeling code is below.

ods output estimates= ests lsmeans= lsms diffs= diffs;

proc mixed data=eff_pop method = reml;

class subj trt visit agegroup hist;

model chg = trt visit agegroup trt*visit trt*agegroup visit*agegroup trt*visit*agegroup base cont hist / ddfm=kr solution outp=predict;

repeated visit / type=un subject=subj;

lsmeans trt01pn|avisitn/ pdiff=all cl;

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use the LSMEANS statement on the 3-way interaction to show the estimates and order of the means. Then use an LSMESTIMATE statement to test the joint hypothesis of the pairwise differences of the ones you want to compare. For example, the following compares the first three and abbreviation treatment as t, visit as v, and age as a. It will be a 2 df test. For your case, you'll have a lot more zeros in each part to pick out the right means. Be careful to match your coefficients to the order of from the LSMEANS statement.

```
lsmeans t*v*a;
lsmestimate t*v*a '111=112' 1 -1 0, '111=113' 1 0 -1, '112=113' 0 1 -1 / joint;
```

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use the LSMEANS statement on the 3-way interaction to show the estimates and order of the means. Then use an LSMESTIMATE statement to test the joint hypothesis of the pairwise differences of the ones you want to compare. For example, the following compares the first three and abbreviation treatment as t, visit as v, and age as a. It will be a 2 df test. For your case, you'll have a lot more zeros in each part to pick out the right means. Be careful to match your coefficients to the order of from the LSMEANS statement.

```
lsmeans t*v*a;
lsmestimate t*v*a '111=112' 1 -1 0, '111=113' 1 0 -1, '112=113' 0 1 -1 / joint;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you, this is perfect, I didn't know about the JOINT option. Just for any others looking at this post, here is the final code with I believe all the correct zeros and everything.

ods output lsmeans=lsms lsmestimate=lsmests; proc mixed data=eff_pop method = reml; class subj trt visit agegroup hist; model chg = trt visit agegroup trt*visit trt*agegroup visit*agegroup trt*visit*agegroup base cont hist / ddfm=kr solution outp=predict; repeated visit / type=un subject=subj; lsmeans trt*visit*agegroup; lsmestimate trt*visit*agegroup 'Difference within age group 1 at visit 4, trt 1 vs. 2' 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 'Difference within age group 2 at visit 4, trt 1 vs. 2' 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 'Difference within age group 3 at visit 4, trt 1 vs. 2' 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0/ joint; run; ods rtf close;

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.