DATA Step, Macro, Functions and more

Add upper and lower confidence limit CDF curves

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 130
Accepted Solution

Add upper and lower confidence limit CDF curves

[ Edited ]

What I try to do are:

(1) add upper and lower confidence limit curves for data1 (say at 95% confidence level); and

(2) use the same x axis for the merged CDF graph (the graph below has two x axis overlay).

 

I have tried several options like CIPCTLDF or CIPCTLNORMAL for confidence limit curves, no progress. Too late at night, brain doesn't function well &_& Thank you for your kindly help.

 

proc greplay nofs igout=gseg; delete _all_; run;

goptions nodisplay;
      ods graphics off;
      proc univariate data=data1 noprint ;
        cdf nr5m / normal(color=red)
                   name='FIGURE1'
                   height=2;
        inset normal(mu sigma) / header='NR5M' position=nw  height=2 ;
      run;
      quit;

      proc univariate data=data2 noprint;
        cdf nr1000m / normal(color=blue)
                      name='FIGURE2'                
                      height=2;
        inset normal(mu sigma) / header='NR1000M' position = (0.65, 85)  refpoint = tl  height=2;
      run;
      quit;

	  title 'CDF of Data1 and Data2';
      goptions display;
      proc greplay igout=work.gseg tc=sashelp.templt template=whole nofs;
        treplay 1:FIGURE1 1:FIGURE2;
      run;

      ods graphics on;

CDF 1and2.jpg


Accepted Solutions
Solution
‎12-06-2016 05:16 PM
Super User
Posts: 10,046

Re: Add upper and lower confidence limit CDF curves

How about this one :



ods select none;
ods output  CDFPlot=cdfplot Quantiles=quantiles;
proc univariate data=sashelp.class  CIPCTLNORMAL(type=twosided alpha=0.05);
 var weight height;
 cdf weight height/normal ;
run;
ods select all;
data quantiles;
 set quantiles;
 percent=input(scan(quantile,1,'%'),best.);
run;

data have;
 set quantiles cdfplot;
run;

proc sgplot data=have noautolegend;
band y=percent lower=lclnormal upper=uclnormal/group=varname transparency=0.6;
step x=ecdfx y=ecdfy/group=varname;
series x=cdfx y=cdfy/group=varname name='x';
keylegend 'x' / position=topleft location=inside across=1;
xaxis label=' ';
run;

View solution in original post


All Replies
Solution
‎12-06-2016 05:16 PM
Super User
Posts: 10,046

Re: Add upper and lower confidence limit CDF curves

How about this one :



ods select none;
ods output  CDFPlot=cdfplot Quantiles=quantiles;
proc univariate data=sashelp.class  CIPCTLNORMAL(type=twosided alpha=0.05);
 var weight height;
 cdf weight height/normal ;
run;
ods select all;
data quantiles;
 set quantiles;
 percent=input(scan(quantile,1,'%'),best.);
run;

data have;
 set quantiles cdfplot;
run;

proc sgplot data=have noautolegend;
band y=percent lower=lclnormal upper=uclnormal/group=varname transparency=0.6;
step x=ecdfx y=ecdfy/group=varname;
series x=cdfx y=cdfy/group=varname name='x';
keylegend 'x' / position=topleft location=inside across=1;
xaxis label=' ';
run;

SAS Super FREQ
Posts: 3,755

Re: Add upper and lower confidence limit CDF curves

To add to KSharp's suggestion, you can also use the OUTPUT statement and the PCTLPTS= option to obtain the CIs on a denser set of quantiles. See the article "Compute confidence intervals for percentiles in SAS," which also shows how to handle the case of non-normal data.

Frequent Contributor
Posts: 130

Re: Add upper and lower confidence limit CDF curves

Thank you Ksharp and Rick as always!

Frequent Contributor
Posts: 130

Re: Add upper and lower confidence limit CDF curves

[ Edited ]

One more question.

 

In my dataset there are two variables, one variable is for actual data and the other one for simulated. 

Is there any option to add bands only to simulated data's CDF curve? or, can I set band color as transparent for actual data (so that its bands will be unvisible)?

 

For example, can I hide the bands for weight, and only keep bands for hight? I've tried several options, and haven't figure out yet.

Super User
Posts: 10,046

Re: Add upper and lower confidence limit CDF curves

OK. Call missing of them if you don't want.

data have;
 set quantiles cdfplot;
run;
--------->
data have;
 set quantiles cdfplot;
 if VarName='Height' then call missing(lclnormal,uclnormal);
run;


Frequent Contributor
Posts: 130

Re: Add upper and lower confidence limit CDF curves

That's pretty neat, thank you Ksharp!

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 326 views
  • 6 likes
  • 3 in conversation