## One-sided exact (Clopper-Pearson) interval

Occasional Contributor
Posts: 11

# One-sided exact (Clopper-Pearson) interval

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

Posts: 2,655

## Re: One-sided exact (Clopper-Pearson) interval

Posted in reply to oskarseriksson

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

Occasional Contributor
Posts: 11

## Re: One-sided exact (Clopper-Pearson) interval

Posted in reply to SteveDenham

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

Posts: 2,655

## Re: One-sided exact (Clopper-Pearson) interval

Posted in reply to oskarseriksson

There may be a problem with coverage in an exact interval.  In the documentation for PROC FREQ (Detailstatistical 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

Occasional Contributor
Posts: 11

## Re: One-sided exact (Clopper-Pearson) interval

Posted in reply to SteveDenham

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

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