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

Godfrey, Jonathan A.J.Godfrey at massey.ac.nz
Thu Jan 7 03:33:09 UTC 2021


Hello Amy,

You didn't need to put in the probabilities as your input is what is used by default. It didn't hurt though. The rest of your code is fine.

I typed chisq.test(c(0,13,17)) and got what I expected.

(-10)^2/10 + 3^2/10 + 7^2/10 = 15.8
The p value is less than 0.0004

I wonder if you are smarter than the person using SPSS? (don't answer that) You must be because you're using R.

Then, to avoid the copy and paste thing, I recommend you get into R markdown as soon as you can.


HTH
Jonathan


-----Original Message-----
From: BlindRUG <blindrug-bounces at nfbnet.org> On Behalf Of Amy Albin via BlindRUG
Sent: Thursday, 7 January 2021 3:45 PM
To: blindrug at nfbnet.org
Cc: Amy Albin <amyralbin at gmail.com>
Subject: [BlindRUG] /Chi-square goodness of fit test with R not working

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

_______________________________________________
BlindRUG mailing list
BlindRUG at nfbnet.org
http://nfbnet.org/mailman/listinfo/blindrug_nfbnet.org
To unsubscribe, change your list options or get your account info for BlindRUG:
http://nfbnet.org/mailman/options/blindrug_nfbnet.org/a.j.godfrey%40massey.ac.nz
The list archive can be viewed at:
http://www.nfbnet.org/pipermail/blindrug_nfbnet.org
More information and useful links about using R as a blind person can be obtained at:
http://R-Resources.massey.ac.nz

Look for help using R commands by reading the accessible e-book "Let's Use R Now" compiled by Jonathan Godfrey at:
http://R-Resources.massey.ac.nz/lurn/front.html


More information about the BlindRUG mailing list