BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
reedwinter
Calcite | Level 5

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).

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

View solution in original post

12 REPLIES 12
ballardw
Super User

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.

 

reedwinter
Calcite | Level 5

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);

 

ballardw
Super User

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.

 

reedwinter
Calcite | Level 5

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.

 

ballardw
Super User

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?

reedwinter
Calcite | Level 5

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?

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

PGStats
Opal | Level 21

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
reedwinter
Calcite | Level 5

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).

PGStats
Opal | Level 21

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
reedwinter
Calcite | Level 5

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

What if the catergorical variable is random effect?

SteveDenham
Jade | Level 19

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Discussion stats
  • 12 replies
  • 3681 views
  • 4 likes
  • 5 in conversation