## Confidence Bands Formula in PROC REG

Solved
Regular Contributor
Posts: 239

# Confidence Bands Formula in PROC REG

I have used PROC REG to generate a stability chart.  I plotted the observed values and then added a linear prediction line and 95% confidence bands.  I also added a horizontal reference line to represent the acceptance criteria.  I know that SAS provides the parameter estimates for the linear prediction line, so I am able to calculate at exactly which x value will the line cross the reference line.  However, I'm not sure where to find the information to find when the confidence bands cross the reference line.

Example:

Running the code below will produce a plot with a reference line at y=1 and a prediction line that crosses y=1 at x=41.1487.  I got this from the parameter estimates (intercept=0.04000, month=0.02333:  1=0.04 + 0.02333*x --> x=41.1487).

Is there anything in the SAS output that will help me determine at exact which month the 95% confidence bands cross the y=1 reference line?

``````data stability;
input Month B;
cards;
0	0.00
3	0.15
6	0.17
9	0.27
12	0.33
18	0.44
;
run;

proc reg data=stability;
model B=month / cli;
output out=reg p=pred ucl=upper lcl=lower;
quit;

proc sgplot data=reg;
scatter x=month y=B / name='PlotChar' markerattrs=(symbol=diamond) legendlabel='B';
series x=month y=pred / name='Pred' legendlabel='Regression line' lineattrs=(pattern=1 thickness=2 color=black);
series x=month y=upper / name='Upper' legendlabel='95% Confience limits' lineattrs=(pattern=2 thickness=1 color=black);
series x=month y=lower / lineattrs=(pattern=2 thickness=1 color=black);
refline 1 / name='RefLine' lineattrs=(pattern=4 thickness=2 color=black) legendlabel="Acceptance criteria";
xaxis label='Time Point (Months)' values=(0 to 48 by 3);
yaxis label="B" values=(0 to 1.3 by 0.1);
keylegend 'PlotChar' 'Pred' 'Upper' 'RefLine' / position=bottom;
run;``````

Accepted Solutions
Solution
‎10-07-2015 04:42 PM
SAS Super FREQ
Posts: 3,834

## Re: Confidence Bands Formula in PROC REG

Posted in reply to djbateman

You can use PROC PLM to score the regression model on an evenly spaced grid of points. If necessary, you can use interpolation to get as close as you want.

Before I show the code, I feel compelled to say that extrapolation of linear models is probably a bad idea. These are not forecasting procedures, and I'm not even sure what a "95% confidence interval for individual preditions" means when you are outside of the range of the data. You can do it, but it might be meaningless.

For information about scoring regression models by using PROC PLM, see "Techniques for scoring a regression model in SAS"

``````proc glm data=stability noprint;
model B=month;
store work.RegModel;
quit;

data ScoreX;
do Month = 0 to 41 by 0.1;
output;
end;
run;

proc plm restore=RegModel noprint;
score data=scoreX out=FitOut pred=Fit LCL=LCL UCL=UCL;
run;

proc print data=FitOut;
where UCL > 0.99 and UCL < 1.01;
run;``````

All Replies
Respected Advisor
Posts: 2,048

## Re: Confidence Bands Formula in PROC REG

Posted in reply to djbateman

You could interpolate the UPPER and LOWER, this would not give you an exact answer, but it would probably be close enough.

Or, you could look up the formula for the regression confidence intervals in just about any statistics text that covers regression, and then use that formula. This ought to give you an exact confidence interval.

--
Paige Miller
Solution
‎10-07-2015 04:42 PM
SAS Super FREQ
Posts: 3,834

## Re: Confidence Bands Formula in PROC REG

Posted in reply to djbateman

You can use PROC PLM to score the regression model on an evenly spaced grid of points. If necessary, you can use interpolation to get as close as you want.

Before I show the code, I feel compelled to say that extrapolation of linear models is probably a bad idea. These are not forecasting procedures, and I'm not even sure what a "95% confidence interval for individual preditions" means when you are outside of the range of the data. You can do it, but it might be meaningless.

For information about scoring regression models by using PROC PLM, see "Techniques for scoring a regression model in SAS"

``````proc glm data=stability noprint;
model B=month;
store work.RegModel;
quit;

data ScoreX;
do Month = 0 to 41 by 0.1;
output;
end;
run;

proc plm restore=RegModel noprint;
score data=scoreX out=FitOut pred=Fit LCL=LCL UCL=UCL;
run;

proc print data=FitOut;
where UCL > 0.99 and UCL < 1.01;
run;``````
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 296 views
• 0 likes
• 3 in conversation