BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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
Rick_SAS
SAS Super FREQ

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 2890 views
  • 0 likes
  • 3 in conversation