# Re: [R] chisq.test

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 08 Aug 2005 - 17:27:51 EST

"Stephen Choularton" <mail@bymouth.com> writes:

> Hi
>
> I am trying to use this function. Can anyone show me how I would input
> the following example?
>
> Chi-Squared = (40-30)^2 + (20-30)^2 + (30-30)^2
> 30 30 30
>
> = 3.333 + 3.333 + 0 = 6.666 (p value = 0.036)

> chisq.test(c(40,30,20))

Chi-squared test for given probabilities

data: c(40, 30, 20)
X-squared = 6.6667, df = 2, p-value = 0.03567

>
> I want to be able to use different denominators so can you show me how I
> can do it to accommodate these rather than assuming they are all the
> same.

No. You want to test different *hypotheses* about the distribution on  the three groups. E.g. for 2:1:1 split:

> chisq.test(c(40,30,20),p=c(.5,.25,.25))

Chi-squared test for given probabilities

data: c(40, 30, 20)
X-squared = 3.3333, df = 2, p-value = 0.1889

```--
O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help