Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Looking for alternatives to estimate stements in proc mixed

Options

- 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** and **locked**.
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 01-23-2019 04:42 PM
(1862 views)

I have data for series of n-of-1 trials. Would like to estimate individual treatment effects from a linear mixed effects model with "proc mixed". To obtain the estimates for each individual, the procedure involves writing an "estimate" statement for each individual available in the dataset. I am looking for a simpler alternative which does not involve writing all the "estimate" statements. Currently I know that a macro can be written to deal with this issue. However, somebody else suggested the same could be accomplished more efficiently through some options of the "lsmeans" or "slice" statements. I have tried this approach and get the following error:

ERROR: Effects used in the LSMEANS statement must have appeared previously in the MODEL statement.

or in case a "slice" statement is used instead:

ERROR: Effects used in the SLICE statement must have appeared previously in the MODEL statement.

Since the desired effects are in the "random" statement, and are absent from the "model" statement, this approach does not work! I wonder if there is some hidden way to accomplish this more efficiently, without resorting to the macro language.

Below is the code, with the data step, and the suggested alternatives. The first approach uses the "estimate" statements to obtain the desired individual treatment effect estimates. The second and third approaches attempt a "lsmeans" and "slice" statements respectively.

Thanks in advance.

```
data WORK.ndata;
infile datalines;
input Patient Treatment $ Cycle $ Period $ Y;
datalines;
1 A 1 1 2394
1 B 1 2 2686
1 A 2 3 2515
1 B 2 4 2675
1 A 3 5 2583
1 B 3 6 2802
2 A 1 1 2746
2 B 1 2 2726
2 A 2 3 2592
2 B 2 4 2867
2 A 3 5 2743
2 B 3 6 2742
3 A 1 1 2668
3 B 1 2 2560
3 A 2 3 2542
3 B 2 4 2584
3 A 3 5 2491
3 B 3 6 2737
4 A 1 1 2397
4 B 1 2 2696
4 A 2 3 2411
4 B 2 4 2895
4 A 3 5 2499
4 B 3 6 2760
5 A 1 1 3179
5 B 1 2 3221
5 A 2 3 2952
5 B 2 4 3096
5 A 3 5 2600
5 B 3 6 3192
6 A 1 1 2643
6 B 1 2 2496
6 A 2 3 2759
6 B 2 4 2847
6 A 3 5 2651
6 B 3 6 2860
7 A 1 1 2678
7 B 1 2 2843
7 A 2 3 2492
7 B 2 4 2763
7 A 3 5 2801
7 B 3 6 2890
8 A 1 1 2887
8 B 1 2 2862
8 A 2 3 2875
8 B 2 4 3083
8 A 3 5 2689
8 B 3 6 2967
9 A 1 1 2490
9 B 1 2 2841
9 A 2 3 2648
9 B 2 4 3044
9 A 3 5 2688
9 B 3 6 2914
10 A 1 1 2268
10 B 1 2 2576
10 A 2 3 2413
10 B 2 4 2493
10 A 3 5 2344
10 B 3 6 2699
11 A 1 1 2617
11 B 1 2 2923
11 A 2 3 2629
11 B 2 4 2832
11 A 3 5 2732
11 B 3 6 2866
12 A 1 1 2627
12 B 1 2 2759
12 A 2 3 2712
12 B 2 4 2698
12 A 3 5 2572
12 B 3 6 2826
run;
title;
proc mixed
data=WORK.ndata
alpha=0.05 /* level for CI */
cl /* CI for covariance parameters */
method=REML; * REML method for estimation ;
class Treatment (ref=first) Patient Cycle;
model Y = Treatment /
htype=2; * type 2 hypothesis test ;
random Patient Patient*Cycle Patient*Treatment;
estimate 'B-A,1' Treatment 1 -1 |
Patient*Treatment 1 0 0 0 0 0 0 0 0 0 0 0
-1 0 0 0 0 0 0 0 0 0 0 0 /
alpha=0.05 /* level for CI */
cl; * t-type CI for estimates ;
estimate 'B-A,2' Treatment 1 -1 |
Patient*Treatment 0 1 0 0 0 0 0 0 0 0 0 0
0 -1 0 0 0 0 0 0 0 0 0 0;
estimate 'B-A,3' Treatment 1 -1 |
Patient*Treatment 0 0 1 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 0 0 0 0;
estimate 'B-A,4' Treatment 1 -1 |
Patient*Treatment 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0 0 0 0;
estimate 'B-A,5' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 -1 0 0 0 0 0 0 0;
estimate 'B-A,6' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 -1 0 0 0 0 0 0;
estimate 'B-A,7' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 -1 0 0 0 0 0;
estimate 'B-A,8' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 -1 0 0 0 0;
estimate 'B-A,9' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 -1 0 0 0;
estimate 'B-A,10' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 -1 0 0;
estimate 'B-A,11' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 -1 0;
estimate 'B-A,12' Treatment 1 -1 |
Patient*Treatment 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 -1;
run;
title;
proc mixed
data=WORK.ndata
alpha=0.05 /* level for CI */
cl /* CI for covariance parameters */
method=REML; * REML method for estimation ;
class Treatment (ref=first) Patient Cycle;
model Y = Treatment /
ddfm=KR /* inference based on Kenward and Roger's method */
htype=2; * type 2 hypothesis test ;
random Patient Patient*Cycle Patient*Treatment;
lsmeans Patient*Treatment /
slice=Patient
diff;
run;
* Look at the Log and note that the "lsmeans" statement cannot
be used to compute individual treatment effects with proc mixed;
title;
proc mixed
data=WORK.ndata
alpha=0.05 /* level for CI */
cl /* CI for covariance parameters */
method=REML; * REML method for estimation ;
class Treatment (ref=first) Patient Cycle;
model Y = Treatment /
ddfm=KR /* inference based on Kenward and Roger's method */
htype=2; * type 2 hypothesis test ;
random Patient Patient*Cycle Patient*Treatment;
slice Patient*Treatment /
sliceBy=Patient
diff;
run;
* Look at the Log and note that the "slice" statement cannot
be used to compute individual treatment effects with proc mixed;
```

1 ACCEPTED SOLUTION

Accepted Solutions

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

2 REPLIES 2

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

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

Thanks a lot Rick. That answers my question.

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.