how to plot confidence interval with v9.1

Reply
Occasional Contributor
Posts: 7

how to plot confidence interval with v9.1

From PROC LOGISTIC output, I had a dataset including predicted, lower and upper 95% confidence interval, and measurement (a continuous variable). How can I have a plot to show the confidence interval band in SAS v9.1?

Many thanks.

Shellee

Super User
Posts: 11,343

Re: how to plot confidence interval with v9.1

I don't think the SG graphics are available in 9.1.3 so Gplot may be what you need.

Something like (asumes Measure is your horizontal axis).

symbol i=join;

proc gplot data=have;

     plot lcl*measure predicted*measure ucl*measure /overlay

                              areas=2;

run;

quit;

Or possibly something from

http://support.sas.com/kb/25/506.html

will be appropriate

Or if you want a legend and lines instead of areas transform data.

Data want (keep=measure plotval plottype);

     set have;

     Plotval=LCL; PlotType='LCL'; output;

     Plotval=Predicted; PlotType='Predicted'; output;

     Plotval=UCL; PlotType='UCL'; output;

run;

symbol1 i=join c=red;

symbol2 i=join c=blue;

symbol3 i=join c=black;

/* may want to play with the colors and line type options on symbol as well*/

proc gplot data=want;

     plot Plotval*measure=PlotType;

run;

quit;

Occasional Contributor
Posts: 7

Re: how to plot confidence interval with v9.1

Thanks so much, Ballardw.

I am using the line option. There are two treatments, and how can I overlay these two groups? Also is there anyway to get shade between upper and lower interval in each group? Is it possible to get smooth lines?

Thanks,

Shellee

Super User
Posts: 11,343

Re: how to plot confidence interval with v9.1

To answer the last question first. Look at the interpolation options on the Symbol statement. The L1P L3P and L5P are some polynomial spline fits of different degrees of smoothness or SMnn where nn is 1 to 99, or Spline. All use different algorithms to smooth, I would experiment to see which ones appear to best fit for your use.

Since Gplot doesn't deal with transparency if the data are very similar and would overlap anything shading between the upper and lower bounds will only show the top layer clearly. That is why many users liked the introduction of the SG graphics and the GTL to allow transparency. I'm not sure of anyway with SAS 9.1 to get the type of overlay I think you're asking for though it may be possible with lots of coding using DSGI but you would likely need to do a lot of coding.

The AREAS option is what controls shading between lines. I don't use this much, it think mayber the areas=3 with the third example I provided and setting the symbol1 to the background color may be closer to what you want for one group but wouldn't work with two.

Occasional Contributor
Posts: 7

Re: how to plot confidence interval with v9.1

Thanks, Ballardw.


I will try as what you suggest after I have done the more urgent and newly assigned task for this project.


I will let you know how it turns out.


Thanks a lot!


Shellee

Ask a Question
Discussion stats
  • 4 replies
  • 264 views
  • 0 likes
  • 2 in conversation