[R] Chi-squared test
P Ehlers
ehlers at math.ucalgary.ca
Thu Nov 24 13:07:52 CET 2005
Bianca Vieru- Dimulescu wrote:
> Hello,
>
> I'm trying to calculate a chi-squared test to see if my data are
> different from the theoretical distribution or not:
>
> chisq.test(rbind(c(79, 52, 69, 71, 82, 87, 95, 74, 55, 78, 49,
> 60),c(80,80,80, 80, 80, 80, 80, 80, 80, 80, 80, 80)))
>
> Pearson's Chi-squared test
>
> data: rbind(c(79, 52, 69, 71, 82, 87, 95, 74, 55, 78, 49, 60), c(80,
> 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80))
> X-squared = 17.6, df = 11, p-value = 0.09142
>
> Is this correct? If I'm doing the same thing using Excel I obtained a
> different value of p.. (1.65778E-14)
>
> Thanks a lot,
> Bianca
It would be unusual to have 12 observed frequencies all equal to 80.
So I'm guessing that you have a 12-category variable and want to
test its fit to a discrete uniform distribution. I assume that your
frequencies are
x <- c(79, 52, 69, 71, 82, 87, 95, 74, 55, 78, 49, 60)
Then just use
chisq.test(x)
(see the help page).
(If those 80's are expected cell frequencies, they should sum to
sum(x) = 851.)
I don't know what Excel does.
Peter
Peter Ehlers
University of Calgary
>
> ______________________________________________
> R-help at 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
More information about the R-help
mailing list