Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
linlin87
Quartz | Level 8

Hey everyone at SAS,

My question very simple OK. I have regression with just continuous variable, no CLASS variable.

  proc glm data=in;
  model y = x ; 
  run;
quit;

At specific values of x, I can predict y and have confidence interval for prediction. x1=12 and x2=10 I know the predicted value and the confidence interval around each prediction. But my question how I find confidence interval for the prediction at x1 minus the prediction at x2?

This is what I want to do; find the confidence interval around the difference in predicted values? I have tried using estimate and contrast but not working for a difference in predicted value.

Really appreciate help!

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Start with your fitted model: mean(y)=b0 + b1*x. Using this model, the prediction at x=12 is b0+b1*12. At x=10, it is b0+b1*10. Now, take the difference: mean(y,x=12)-mean(y,x-10)=(b0+b1*12)-(b0+b1*10)=b1*(12-10)=2*b1. Any linear combination of model parameters can be estimated using ESTIMATE statement. For regression models like this, it is best to use PROC ORTHOREG as it is the most modern and supports the full range of modern statements, unlike the old GLM and REG procedures. 

proc orthoreg; 
model y=x; 
estimate 'diff 12-10' x 2 / cl; 
run;

View solution in original post

5 REPLIES 5
StatDave
SAS Super FREQ

Start with your fitted model: mean(y)=b0 + b1*x. Using this model, the prediction at x=12 is b0+b1*12. At x=10, it is b0+b1*10. Now, take the difference: mean(y,x=12)-mean(y,x-10)=(b0+b1*12)-(b0+b1*10)=b1*(12-10)=2*b1. Any linear combination of model parameters can be estimated using ESTIMATE statement. For regression models like this, it is best to use PROC ORTHOREG as it is the most modern and supports the full range of modern statements, unlike the old GLM and REG procedures. 

proc orthoreg; 
model y=x; 
estimate 'diff 12-10' x 2 / cl; 
run;
linlin87
Quartz | Level 8

Thank you StatDave. I no have othoreg. I have this code 

 

proc glm data=test;
model y=x / solution cli clm;
estimate 'difference' x / e;
run;

How I make it give confidence limit?

Thank you for help!

StatDave
SAS Super FREQ
You should if you have SAS/STAT installed - even an pretty old release. Note that it is spelled ORTHOREG - not OTHOREG. You could also use PROC MIXED or PROC GLIMMIX
linlin87
Quartz | Level 8

Is the confidence limit (from estimate statement) a confidence limit around the linear combination of parameters or around the predicted difference?

StatDave
SAS Super FREQ

The ESTIMATE statement estimates the difference, so the CL option provides the confidence interval for that difference. This is true for the ordinary regression model, but note that for a generalized linear model (logistic, Poisson, gamma, etc.) this would not be true. For a generalized linear model that uses a non-identity link function, that ESTIMATE statement would not estimate the difference in means at the two settings and the confidence interval would also not be for that difference.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 983 views
  • 4 likes
  • 2 in conversation