turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How to get standard error of difference of ls-mean...

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-29-2012 04:57 AM

Hi,

how to get the SE of difference of lsmeans in Proc GLM?

How could I calculate it?

Thanks

Clara

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-29-2012 03:56 PM

The standard error of the difference in two least-square means equals the square root of the sum of the squared standard errors of these two least-square means. The following LSMEANS statement in PROC GLM displays the values of the least-square means and their standard errors:

LSMEANS effect / stderr;

You can check this by adding the option, TDIFF, to the LSMEANS statement so that the t-statistic is displayed for all pairwise differences between two least-square means. For each pair, these t-statistics equal the difference between these least-square means divided by the standard error of this difference.

If you want to calculate these standard errors of differences, you can use the ODS statement to write out the LSMEANS and their standard errors to an output SAS data set and to use a subsequent DATA step to perform these calculations.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-29-2012 04:41 PM

Merci !

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-29-2012 09:40 PM

Here is an example of how you can implement 1zmm's advice :

**title 'Unbalanced Two-Way Analysis of Variance';****data a;**** input drug disease @;**** do i=1 to 6;**** input y @;**** output;**** end;**** datalines;****1 1 42 44 36 13 19 22****1 2 33 . 26 . 33 21****1 3 31 -3 . 25 25 24****2 1 28 . 23 34 42 13****2 2 . 34 33 31 . 36****2 3 3 26 28 32 4 16****3 1 . . 1 29 . 19****3 2 . 11 9 7 1 -6****3 3 21 1 . 9 3 .****4 1 24 . 9 22 -2 15****4 2 27 12 12 -5 16 15****4 3 22 7 25 5 12 .****;**

** **

**proc glm data=a plots=none;**** class drug disease;**** model y=drug disease drug*disease;**** lsmeans drug / pdiff=all tdiff CL;**** ods output Diff=aDiff LSMeanDiffCL=aCL;****run;****quit;**

** **

**proc transpose data=aDiff out=aDiffT;****by RowName;****var _:;****run;**

** **

**proc sql;****select **** aCL.*, **** Difference/COL1 as diffStdErr label="Difference Std Err"****from **** aCL inner join **** aDiffT on i = input(RowName,4.) and j = input(_LABEL_, 4.);****quit;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-06-2013 12:08 PM

PGStats,

Coincidentally, my more recent question this week touches on this same subject: Please refer to the question: "How to compute a std err for LSM differences". It appears that the standard error of the LSM difference is much smaller than the standard errors of the two individual LSM's, at least the way SAS computes it (the output came from the LSMEANS statement in PROC GLIMMIX). Steve Denham also computes a higher std err for the LSM diff than the std err of the individual LSM's. Can you account for this discrepancy? Is SAS computing something entirely different?

Ron Levine

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-07-2013 08:36 AM

I think 1zmm gave the correct answer on the other question. It has to do with the covariance between estimates. My earlier method assumes that this value is zero (I assumed independence), and in mixed models, this is almost never the situation.

Steve Denham