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.
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.
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.
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.
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.
Thanks for the help!
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.