# Is a Chi Squared Goodness of Fit Test applicable in this situation?

I conducted research to investigate whether students preferred one particular programming approach to another. Students indicated their gender and answered a series of questions that used a 5-point Likert scale. I am attempting to analyse whether there is a significant difference in the preference of programming approach for each gender individually. For example the question "I preferred learning to program using Platform A more than Platform B" generated the following results for female students:

Strongly Disagree: 0 Disagree: 6 Neutral: 8 Agree: 11 Strongly Agree: 6

There are 31 students, therefore for each answer the expected value ought to be 6.2. Would it be appropriate to calculate a Chi Squared value in this instance?

Yes, you could do that.

Here's the R code to do it:

> chisq.test(c(0, 6, 8, 11, 6))

Chi-squared test for given probabilities

data:  c(0, 6, 8, 11, 6)
X-squared = 10.452, df = 4, p-value = 0.03347


It's a bit of a strange thing to do though - think about the null hypothesis being test - which is that each value is equally likely to be chosen. If that's true, it doesn't mean that they didn't (or did) prefer one language. If half strongly agreed, and half strongly disagreed, there is (overall) no preference, but you reject the null hypothesis:

> chisq.test(c(16, 0, 0, 0, 16))

Chi-squared test for given probabilities

data:  c(16, 0, 0, 0, 16)
X-squared = 48, df = 4, p-value = 9.438e-10


Or if no one cars, and they all put neutral, your result is also highly significant.

I'll second what @JeremyMiles said: you could use a chi-square goodness-of-fit test, but you almost certainly don't want to.

In order to determine a reasonable test, you'll need to decide what you are trying determine with more specificity. To me, the following is not at all clear, and I wouldn't know what test to recommend: "I am attempting to analyse whether there is a significant difference in the preference of programming approach for each gender individually." Are you interested in looking at the differences between genders? Or something within each gender individually?

In any case, you will probably want to treat your Likert data as ordinal. That is, you want a test that knows that 5 is greater than 4, not just that 5 is different than 4.

To compare among genders, a prototypical test would be the Cochran-Armitage test (extended to more than two categories if you have more than two genders). Other tests might be Mood's median test, Mann-Whitney (or Kruskal-Wallis test for more than two genders). Ordinal regression is ideal, but can be a little more complicated to use.

To look at values within a gender, the one-sample sign test or the one-sample Wilcoxon test can determine if the values are significantly different from a default value, say 3 (neutral).