I've read that the chi square test is useful to see if a sample is significantly different from a set of expected values.
For example, here is a table of results of a survey regarding people's favourite colours (n=15+13+10+17=55 total respondents):
red, blue, green, yellow
15, 13, 10, 17
A chi square test can tell me if this sample is significantly different from the null hypothesis of equal probability of people liking each colour.
Question: Can the test be run on the proportions of total respondents who like a certain colour? Like below:
red, blue, green, yellow
0.273, 0.236, 0.182, 0.309
Where, of course, $0.273 + 0.236 + 0.182 + 0.309=1$.
If the chi square test is not suitable in this case, what test would be?
Edit: I tried @Roman Luštrik answer below, and got the following output, why am I not getting a p-value and why does R say "Chi-squared approximation may be incorrect"?
chisq.test(c(0, 0, 0, 8, 6, 2, 0, 0), p = c(0.406197174, 0.088746395,
0.025193306, 0.42041479, 0.03192905, 0.018328576,
0.009190708, 0))
Chi-squared test for given probabilities
data: c(0, 0, 0, 8, 6, 2, 0, 0)
X-squared = NaN, df = 7, p-value = NA
Warning message:
In chisq.test(c(0, 0, 0, 8, 6, 2, 0, 0), p = c(0.406197174,
0.088746395, :
Chi-squared approximation may be incorrect
Best Answer
Correct me if I'm wrong, but I think this can be done in R using this command
This assumes proportions of 1/4 each. You can modify expected values via argument
p
. For example, you think people may prefer (for whatever reason) one color over the other(s).