turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How can I add confidence limits to a fit plot usin...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-07-2016 05:07 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-08-2016 08:43 AM

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-07-2016 09:21 AM - edited 07-07-2016 09:22 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-08-2016 05:17 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-08-2016 08:43 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-08-2016 09:18 AM

Thanks for the help!