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).
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.
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.
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);
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.
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.
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?
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?
I don't know. Maybe you should check EFFECTPLOT statement or EFFECT statement.
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?
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).
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.
This looks like what I am trying to get! Thanks!
What if the catergorical variable is random effect?
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.