1
$\begingroup$

Everything I have read states that one of the conditions for inference of chi-squared is that random sampling is carried out (e.g. https://stattrek.com/chi-square-test/homogeneity.aspx). Can I still use chi-squared on subsets of an entire population (i.e. that together make up the population rather than samples of a population)?

I am doing an analysis project on titanic data (from Kaggle)

One thing I have discovered is that the mean survival rates for adult men, adult women, children and over 60s vary significantly. I want to prove that the differences are statistically significant.

(Note: When I state mean survival rate - The data is in the format where 0=Non-survivor and 1=Survivor. The mean is simply an average of the 1s and 0s for each demographic)

Update: following the responses, I tried using chi squared on my population and this is what I got.

|            |   Observed Survivors    |    Expected Survivors
| Adult Man  |        84               |     191.919192
| Adult Woman|        192              |      98.262626
| Child      |         61              |      43.373737
| Senior     |         5               |       8.444444

Using the data above and the chi-square script method I got a chi squared of 158. This seems very high. Have I done something wrong?

chisquare(f_obs = observed_survivors, f_exp = expected_survivors, ddof=3, axis =0)
$\endgroup$
2
  • $\begingroup$ I'm not sure what you mean in the second sentence of your first paragraph. If your available data is a strict subset of the population then that would be considered a sample, not the entire population. Do you have all the data from the population or not? $\endgroup$
    – Ben
    Commented Dec 28, 2018 at 8:24
  • $\begingroup$ Thanks for your reply @Ben , by subset I mean that it's not random - I have segmented my data to give the four groupings above. The subsets have been chosen because I felt they would result in variation. $\endgroup$
    – Jonny
    Commented Dec 28, 2018 at 15:43

1 Answer 1

1
$\begingroup$

The linked Kaggle page has data for passengers on the Titanic, but it has split this randomly into a training set and a test set. The stated goal of the project is to build a model that you fit to the training set, and then use this to predict survival in the test set. Presumably the training set was a random sample of the set of all passengers used in the project. (If not, that is a problem!)

There are many types of chi-squared test (this term covers any hypothesis test where the null distribution is the chi-squared distribution), but in your case it sounds like you are talking about a test of independence in a contingency table of categorical data. The usual test of independence compares probabilities in the cells, which is implicitly an inference for an infinite population. If you want to incorporate finite-population correction to make inferences only about the test set then you might want to read Rao and Scott (1981), which touches on this issue. However, the usual effect of finite-population correction in these cases is that it changes your confidence/prediction intervals, but does not usually change your point estimators/predictions. Since your goal is to make predictions of a binary variable in the test set, you will be making a point-based prediction, so it is unlikely that adjusting for finite-population will make any difference.

To be clear, implementing a chi-squared test on a contingency table requires you to segment the data into its appropriate categories for the contingency table. That is done non-randomly, and the counts in the categories are for those category types - they are not random samples from the whole population. The test you have used determine whether there is evidence that survival occurs with different probabilities in the categories. The high value for the chi-squared test statistic is not a mistake - it simply reflects extremely strong evidence that the probability of survival across those groups is not equal. In this case you can easily see that women and children were much more likely to survive the disaster than men or seniors.

$\endgroup$
1
  • $\begingroup$ Thanks Ben, I have added the data i'm working with which may help add some context. I'm also going to link the git hub so you can see the study for context. The relevant section is under the heading "Chi-squared test for age/sex groupings" under section 4. $\endgroup$
    – Jonny
    Commented Dec 28, 2018 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.