[BlindRUG] /Chi-square goodness of fit test with R not working

Amy Albin amyralbin at gmail.com
Thu Jan 7 02:45:15 UTC 2021


Hello,

I am working on a data analysis where someone observed drivers and
whether they had 0, 1, or 2 hands on the wheel. The data is there were
0 drivers with 0 hands, 13 drivers with 1 hand, and 17 drivers with 2
hands. I am attempting to use R to perform a chi-square goodness of
fit test. Here is the result I know it’s supposed to be; this is
correct, which someone else generated from IBM-SPSS.
Chi Square = 0.533, DF = 2, P>0.05
Here was my R input.


drivers <- c(0, 13, 17)
res <- chisq.test(drivers, p = c(1/3, 1/3, 1/3))
res


And here is my output from R, which you can see is a completely
different chi-square and p value.


	Chi-squared test for given probabilities

data:  drivers
X-squared = 15.8, df = 2, p-value = 0.0003707

What am I doing wrong? Also what is the best way to copy and paste
code from my terminal into a word doc or email so I don’t have to
retype it like I just did? Thank you.

Best,

Amy Albin
Pronouns: she/her/hers



More information about the BlindRUG mailing list