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 calculate confidence interval of mean respo...

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-12-2016 12:01 PM - edited 08-19-2016 05:40 PM

Hi, I have a multiple regression model: y=x1+x2+e, where x1 is a continuous variable and x2 is a categorical variable (can either be fixed or random). I am trying to get a SE or Confidence interval for mean reponse at given level of x1, such as x1=20. But LSMEANS statement can only used for categorical variable.

Edit on 8/19:

As the accepted solution stated, the BLUE can be estimated as

lsmestimate sex 'Overall LS mean' 1 1 / at height=60 divisor=2 cl;

After some reading, I found another way to do it:

Estimate 'Overall LS mean' intercept 1 height 60/cl;

This statement can also be used in model when the catergorical factor is random effect (sex in this case, although not proper to be treated as random).

Accepted Solutions

Solution

08-17-2016
02:59 PM

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

Posted in reply to reedwinter

08-14-2016 02:25 PM

Then, assuming that you want to give an equal weight to both sexes (in my example), you should request a least squares means estimate:

```
proc glimmix data=sashelp.class;
class sex;
model weight = height sex;
lsmestimate sex 'Overall LS mean' 1 1 / at height=60 divisor=2 cl;
run;
```

Use as many 1's as you have classes and the number of classes as divisor.

PG

All Replies

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

Posted in reply to reedwinter

08-12-2016 12:15 PM - edited 08-12-2016 12:16 PM

Which regression procedure are you using?

It will help to see what your are currently doing and posting the code for the procedure answers many questions you may get asked.

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

Posted in reply to ballardw

08-12-2016 12:42 PM - edited 08-12-2016 12:44 PM

Hi, either proc glm, groc glimmix or proc mixed are working the same.

proc glimmix;

model y=x1 x2; (if x2 is fixed)

model y=x1; random x2 ;(if x2 is random)

run;

I was trying to get the CI of estimated y at x=20 (or other value);

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

Posted in reply to reedwinter

08-12-2016 01:54 PM

Oneway: Add an OUTPUT statement requesting LCL and UCL or possibly LCLMu and UCLMu (probably should include PRED or PredMu as well). This output set will have every observation in the input set with the confidence limit at that point.

Select the values of X1 of interest afterwards.

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

Posted in reply to ballardw

08-12-2016 02:24 PM

The output gives pred and CI for each combination levels of x1*x2, such as x1=20 has different pred and CI at different level of x2. But what I want is the CI overall all x2.

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

Posted in reply to reedwinter

08-12-2016 03:04 PM

If you don't want both variables involved why are they on the model statement?

You may need to describe in more detail how you are intending to use the result as with multiple independent variables in a model there isn't really going to be a confidence limit for the predicted mean from just one variable and the interpretation might be odd.

Are you perhaps trying to take slices across the data?

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

Posted in reply to ballardw

08-12-2016 03:11 PM

With the 'model y=x3 x4;' if x3 and x4 are both catergorical var, lsmeans will give the pred and CI of x3 as main effect at mean level of x4, right? What is the interpretation of this CI then?

Does the meaning of CI different from what I am trying to get from the model y=x1 x2 while x1 is continuous?

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

Posted in reply to reedwinter

08-13-2016 12:29 AM

I don't know. Maybe you should check EFFECTPLOT statement or EFFECT statement.

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

Posted in reply to reedwinter

08-13-2016 04:15 PM

LSMEANS are available for the levels of CLASS variables AT specified values of continuous predictors :

```
proc glimmix data=sashelp.class;
class sex;
model weight = height sex;
lsmeans sex / at height=60 cl;
run;
```

Are you looking for something else?

PG

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

Posted in reply to PGStats

08-14-2016 01:15 PM

I am not looking for the levels of CLASS variables AT specified values of continuous predictors.

I am looking for confidence interval of mean response AT specified values of continuous predictors across all levels of the class variable (either fixed or random if fine).

Solution

08-17-2016
02:59 PM

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

Posted in reply to reedwinter

08-14-2016 02:25 PM

Then, assuming that you want to give an equal weight to both sexes (in my example), you should request a least squares means estimate:

```
proc glimmix data=sashelp.class;
class sex;
model weight = height sex;
lsmestimate sex 'Overall LS mean' 1 1 / at height=60 divisor=2 cl;
run;
```

Use as many 1's as you have classes and the number of classes as divisor.

PG

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

Posted in reply to PGStats

08-15-2016 10:35 AM

This looks like what I am trying to get! Thanks!

What if the catergorical variable is random effect?

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

Posted in reply to reedwinter

08-15-2016 11:42 AM

Then it becomes a question of whether you want eBLUPs for each level of the categorical variable, or the marginal value over all levels of the random effect. See this thread for an excellent discussion of how to get these.

BLUP and the 95% confidence interval of random effect in multilevel model

Steve Denham