Re: [R] p-values

From: Torsten Hothorn <Torsten.Hothorn_at_rzmail.uni-erlangen.de>
Date: Tue 16 Aug 2005 - 22:29:21 EST

On Thu, 4 Aug 2005, Peter Ho wrote:

> HI R-users,
>
> I am trying to repeat an example from Rayner and Best "A contingency
> table approach to nonparametric testing (Chapter 7, Ice cream example).
>
> In their book they calculate Durbin's statistic, D1, a dispersion
> statistics, D2, and a residual. P-values for each statistic is
> calculated from a chi-square distribution and also Monte Carlo p-values.

Hi Peter,

when I understand the example correctly, the main interest is testing independence of the judges' ranking and the ice cream brand, where the judges are interpreted as `blocks' using a chi^2-type statistic based on the rank sums for each ice cream. In R:

ice <- data.frame(judge = factor(rep(c(1:7),rep(3,7))),
                  variety = factor(c(1,2,4,2,3,5,3,4,6,4,5,7,1,5,6,2,6,7,1,3,7)),
                  rank = c(2,3,1,3,1,2,2,1,3,1,2,3,3,1,2,3,1,2,3,1,2))
library("coin")
it <- independence_test(rank ~ variety | judge, data = ice, teststat = "quadtype") it

        Asymptotic General Independence Test

data: rank by

         groups 1, 2, 3, 4, 5, 6, 7
         stratified by judge

T = 12, df = 6, p-value = 0.06197

So without having checked the theory exactly, this looks like being Dubin's D1 statistic with _asymptotic conditional p-value_ (please have a look at coin's vignette which explains what happens here).

The Monte-Carlo p-value can now be computed by 99,999 replications:

pvalue(independence_test(rank ~ variety | judge, data = ice,

       teststat = "quadtype", distribution = approximate(B = 99999)))

[1] 0.01778018
99 percent confidence interval:
 0.01672170 0.01888482

which seems to be a little bit smaller than 0.02.

Hope that helps,

Torsten

>
> I have found similar p-values based on the chi-square distribution by
> using:
>
> > pchisq(12, df= 6, lower.tail=F)
> [1] 0.0619688
> > pchisq(5.1, df= 6, lower.tail=F)
> [1] 0.5310529
>
> Is there a way to calculate the equivalent Monte Carlo p-values?
>
> The values were 0.02 and 0.138 respectively.
>
> The use of the approximate chi-square probabilities for Durbin's test
> are considered not good enough according to Van der Laan (The American
> Statistician 1988,42,165-166).
>
>
> Peter
> --------------------------------
> ESTG-IPVC
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 16 22:34:05 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:23:31 EST