Re: [R] Mid-P value for a chi-squared test

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sun, 13 Jun 2010 15:47:59 -0400

On Jun 13, 2010, at 2:19 PM, (Ted Harding) wrote:

> On 13-Jun-10 17:12:45, David Winsemius wrote:
>> On Jun 1, 2010, at 4:17 AM, Wilson, Andrew wrote:
>>
>>> Can anyone tell me how to calculate a mid-p value for a chi-squared
>>> test in R?
>>
>> I cannot see that this has been answered. It has a date from 12 days
>> ago but I cannot see a reply in the archives.
>>
>> So, what is a "mid-p value" and which "chi-square test" are you
>> about? A simple data setup in R code with expected output would
>> speed
>> this discussion along.
>>
>> David Winsemius, MD
>
> The "mid-p value" is a device for improving the accuracy of a
> continuous
> approximation to a distribution which in reality is discrete.
>
> Intuitively, the idea is to treat the discrete probabilities of the
> discrete distribution as if they were proportions in a histogram.
> Then imagine fitting a continuous curve (e.g. a chi-squared density)
> to the histogram. The fit (agreement between the proportion in one
> histogram bar, and the probability below that portion of the curve
> which lies in the same range) will be better if the curve goes through
> the midpoint of the top of the bar.
>
> This leads to the formal definition:
>
> "mid-P" = Prob(X > Xobs) + 0.5*Prob(X = Xobs)

Looking at Agresti and Gottard's piece, cited by one of the R functions, midPci {PropCIs} from a match to your suggested search strategy below, they say the lower mid-p CI would be defined as solving equation:

Pr_0L (X > x) + 1/2 x Pr_0L (X = x) = a/2.

Is that mathematically equivalent ( perhaps the NP "dual" to a p-value version) to what you offered? And is the upper CI then defined as solution to :

Pr_0U (X < x) + 1/2 x Pr_0U (X = x) = 1-a/2 ,,, ?

> A number of R functions use this idea. Check out what you get by
> going to http://finzi.psych.upenn.edu/nmz.html and entering "mid-p"
> into the search box, and see whether any of them match (or come
> close to) your particular case.
>
> In the case of the chi-squared test, the idea is related to (but
> not the same as) the "Yates correction for continuity". chisq.test()
> has an option "correct=TRUE" to force this, but only for 2x2 tables.
>
> Ted.
>

David Winsemius, MD
West Hartford, CT

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 13 Jun 2010 - 19:50:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 13 Jun 2010 - 20:50:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.