BookmarkSubscribeRSS Feed
oskarseriksson
Calcite | Level 5

Hi!

I have a small problem when it comes to computing one-sided clopper-pearson confidence intervals for a binomial proportion.

I have 1007 failures (coded 0) and 1 success (coded 1) in a dataset. I want an exact one-sided upper confidence limit for the success.

This is the code I used so far.

proc freq data=x;

tables y / alpha=.01 binomial exact cl;

run;

Nothing complicated, but I've browsed the web for a while now and I can't find where I'm supposed to type what in order to get a one-sided interval instead of a two-sided. I managed to get a one-sided interval with some other code, but I wasn't sure that it was a Clopper-Pearson interval and therefore I could not use it. And it's really important that I obtain a Clopper-Pearson interval.

Thanks for helping out,

Oskar

4 REPLIES 4
SteveDenham
Jade | Level 19

The value you get for the two sided, with alpha=0.01 is equal to the one-sided alpha of 0.005. (alpha=0.1 two-tailed = 0.05 one-tailed).

Steve Denham

oskarseriksson
Calcite | Level 5

Hi Steve!

Thank you!

That's correct, but it doesn't quite solve my problem entirely. The main reason is that the two-sided interval with half the alpha-value returns a wider interval than necessary.

So I'd very much appreciate a way to code a one-sided interval instead. And it needs to be an exact interval (i.e. Clopper-Pearson).

Best regards,

Oskar Eriksson

SteveDenham
Jade | Level 19

There may be a problem with coverage in an exact interval.  In the documentation for PROC FREQ (Details:Statistical Computations:Binomial Proportions), there is a statement that the confidence interval is conservative and unless the sample size is large, the actual covarage probability can be much larger thatn the target.  So, because this becomes a discrete problem, you may be getting a wider interval than you might expect--the boundary HAS to be defined by some integer value m such that prob(m/N)>=alpha.

Also, it gives the formulas for calculating the boundaries, and you can see that for a 95% interval (two-sided), it plugs in alpha/2 = 0.025.  Thus a 90% interval two sided will give a one-sided bound because the Clopper-Pearson interval is constructed by inverting the equal-tailed test.  It's just bigger than you might expect due to the granularity of the data.

Steve Denham

oskarseriksson
Calcite | Level 5

Now I feel a bit stupid! How did I not consider the option to go for a wider two-sided?!

Regarding the coverage probability exceeding 1-alpha, that is sort of important for this particular inference given the sensitive context the results will be used in.

Thanks for walking me around the obstacle! Maybe someday there'll be a possibility to code a one-sided more easily.

My gratitude,

Oskar Eriksson

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 6083 views
  • 1 like
  • 2 in conversation