Programming the statistical procedures from SAS

How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

I am using a nonparametric quantile regression with quadratic B-splines. Now I want to add the confidence bands to the fit plot. But I couldn't find an implementation in SAS 9.4. I have already checked the user's guide but got only a solution in SAS 9.2. Therefore I tried the following:

ods graphics on;
proc quantreg data=data1 algorithm=simplex ci=resampling;
effect Var2=spline(Var1 / Basis=Bspline Details degree=2 knotmethod=list(14));
model Var3 = Var2 / plot=fitplot(showlimits) quantile= 0.05 0.5 0.95 seed=1268;
output out=data2 pred=p / columnwise;
run;
ods graphics off;


But it doesn't seem to work in SAS 9.4. I always get the fit plot but without any confidence limits. I did the same without a spline effect but again no additional bands.

Is there another way in order to display the confidence intervals in SAS 9.4?

Many thanks for the answer.


Accepted Solutions
Solution
‎07-08-2016 09:18 AM
SAS Super FREQ
Posts: 3,306

Re: How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

As it says in the documentation for the QUANTREG procedure:

You can use the PLOTS= option in the MODEL statement ... to request the quantile process plot in addition to all that plots that you request in the PLOT= option in the PROC QUANTREG statement. ...The plot-option in the PROC QUANTREG statement overwrites the plot-option in the MODEL statement .

 

Since you specified the PLOT= option on the MODEL statement, it overrode the MAXPOINTS= option that you specified on the PROC QUANTREG statement. To get what you want, do this:

proc quantreg data=MyData plot(maxpoints=NONE)=fitplot(showlimits) ...;
effect Var2=spline(...);
model Y = Var2 / quantile= 0.05 0.5 0.95 seed=1268;
run;

With 7k points, the confidence bands are likely to be very thin.

 

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,306

Re: How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

[ Edited ]

Have you checked the SAS log to make sure that you are not getting an error somewhere? This example works for me at SAS 9.4m3:

 

proc quantreg data=sashelp.cars algorithm=simplex ci=resampling;
effect Var2=spline(weight / Basis=Bspline Details degree=2 knotmethod=list(3577));
model mpg_city = Var2 / plot=fitplot(showlimits) quantile= 0.05 0.5 0.95 seed=1268;
output out=data2 pred=p / columnwise;
run;

 

 

With your code you are specifying one internal knot at Var1=8.  Depending on the range/distribution of your data, this might cause a problem. You could also try KNOTMETHOD=EQUAL(1) or KNOTMETHOD=EQUAL(2) to get equally space internal knots within the range of Var1.

 

If you can run the Sashelp.Cars example, the problem must be specific to your data.

Contributor
Posts: 29

Re: How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

I have found the error. The problem is, that my data set contains around 7k observations. Therefore I have to add "plot(maxpoints=7000)" to the proc statement in order to get fit plots. And this results in missing confidence bands. I have already tried to increase the number but the intervals are still not visible.

Is there a solution to this problem?

Thanks in advance.

Solution
‎07-08-2016 09:18 AM
SAS Super FREQ
Posts: 3,306

Re: How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

As it says in the documentation for the QUANTREG procedure:

You can use the PLOTS= option in the MODEL statement ... to request the quantile process plot in addition to all that plots that you request in the PLOT= option in the PROC QUANTREG statement. ...The plot-option in the PROC QUANTREG statement overwrites the plot-option in the MODEL statement .

 

Since you specified the PLOT= option on the MODEL statement, it overrode the MAXPOINTS= option that you specified on the PROC QUANTREG statement. To get what you want, do this:

proc quantreg data=MyData plot(maxpoints=NONE)=fitplot(showlimits) ...;
effect Var2=spline(...);
model Y = Var2 / quantile= 0.05 0.5 0.95 seed=1268;
run;

With 7k points, the confidence bands are likely to be very thin.

 

Contributor
Posts: 29

Re: How can I add confidence limits to a fit plot using proc quantreg in SAS 9.4?

Thanks for the help!

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 218 views
  • 0 likes
  • 2 in conversation