Chi-Square Test: Know about the Inferential Statistical test that Operates on Categorical Variables

Statistical test can be complex but it verifies & assures the quality of the study. In analytical work, the most crucial task is the comparison of data (sets of data) and making interpretations.

Inferential statistics, one among the two major branches of statistics, are concerned with making inferences based on the relationships found in the sample, to that in the population. This kind of statistics back the hypothesis, and such inferential test that supports the existence of group differences in the entire population is the Chi-Square test.

The Chi-Square test assumes (the null hypothesis) that the observed values match the expected values for categorical data. Chi-Square test is of two types,

  1. Chi-Square goodness-of-fit test – This test is performed for one categorical value and begins with hypothesizing that variable distribution behaves in a specific manner. For example, in order to identify the daily staffing needs of a store, the manager would wish to know if there is any consistency in the number of customers throughout the week.
  2. Chi-Square test for independence – This test is conducted for two categorical values. It compares variables in a contingency table & investigates if they are related. However, if the observed data doesn’t fit the model, the likelihood that the variables are dependent enhances, proving that the null hypothesis is incorrect.

For instance, this test can help us determine if the DRE is independent of biopsy results.

Chi-Square goodness-of-fit and test for independence depends only on the degrees of freedom and set of observed and expected values. These tests do not require any assumption pertaining to distribution of the parent population. However, if the test is performed along with the standard approximation, the applicability of Chi-Squared distribution, assumptions such as,

  • Simple random sample – It is a random sampling from a fixed population where every individual of the distribution/population of sample size has an equal probability of selection.
  • Constraints on cell frequency must be linear – If a sample with a large size is assumed, but the test is performed on smaller sample size, then the test will yield an inaccurate inference.
  • Theoretical cell frequency must be greater than 5 – As a rule of thumb, the expected cell count of a 2-by-2 table must be 5 or more and, for larger tables, it must be 5 or 80% of the cells.
  • Independence of observations – The observations must be independent of each other, which implies that Chi-Square cannot test correlated data such as matched pairs.

Chi-Square statistics 

Chi-Square test includes calculating a metric known as Chi-square statistic and the formula used here is,

Chi Square statistic

Where, E=(row total×column total) / sample size

Here the subscript ‘c’ indicates degrees of freedom, ‘O’ is the observed value and ‘E’ is the expected value. The summation indicates that the calculation must be done for each data item in the given data set.

Note that the Chi-square statistic cannot be used for percentages, proportions, and be used only on numbers.

For example, if you have 5% of 100 people, you must first convert 5% into the whole number and then run the test.

Chi-Square statistic includes variations which utilise the same concept, i.e., comparing observed & expected values. However, the type of variations used depends on how the data was collected and the hypothesis is being tested.

One of the most common forms of variation used for contingency tables is

Chi-Square statistic

Where E is the expected value, O is the observed value, and “i” is the ith position in the contingency table.

How to determine the statistical significance 

The low value for Chi-Square implies that the correlation between the two sets of data is high. Theoretically, if the observed & expected values are equal, then Chi-Square would be zero, which is practically impossible.

Determining if the test statistic is large enough to specify a statistically significant difference, includes two processes.

  1. Comparing calculated Chi-Square value and critical value from Chi-Square table. If the Chi-Square value is smaller than that of the critical value, there is no significant difference.
  2. Utilising P-value.

To calculate P-value manually,

  1. Firstly, determine the observed & expected values.
  2. This is followed by calculating the degrees of freedom using the formula,

Degrees of freedom = n-1, where ‘n’ is the number of variables.

  1. Compare observed & expected results with Chi-Square value (using the formula mentioned above).
  2. Choose a significance level (in decimals). Most commonly used value is P=0.05.
  3. Use Chi-Square distribution tables and approximate P value.
  4. Determine whether to reject the null hypothesis or not.

Example of Chi-Square test

Consider a random poll was conducted across 1000 voters (both male & female). The individuals who were classified based on their gender and whether they were supporters of party A, B or C.

Party A Party B Party C Total
Male 150 200 50 400
Female 270 300 30 600
Total 420 500 80 1000
  1. Calculate the expected value (E) using the above-mentioned formula
  2. In the second step, calculate the Chi-Square statistic
  3. Sum up all the values of Chi-Square statistics results, identify P-value and determine if the result is statistically significant or not

After obtaining the significant result, you can perform follow-up tests such as post-hoc test, to pinpoint the reasons for the significant result. To know more about it, visit https://www.rforge.net/doc/packages/NCStats/chisqPostHoc.html.

Understanding SPSS Variables: Format, Type and More

If you understand SPSS variable formats and types, it will help you in getting things done accurately and quickly. Learn the format and type of SPSS variables and get in control of your data.

Ascertaining SPSS Variable Formats

SPSS differentiates write and print formats. SPSS variable format comprises of two parts. The format family is indicated by one or more letters. Most the letters speak to themselves, excluding the first two variables:

  • F (Fortran), indicating a standard numeric variable.
  • A (Alphanumeric), the common format for string variables.

Formats end with numbers, which indicate the number of characters which is required to be shown. If you find a period, the number which is present after the period represents the number of decimal places which needs to be displayed.

SPSS Variable Types

SSPS has two variable types, namely numeric and string. String variables may contain numbers, letters and other characters. Numeric variables may include just numbers. The difference between string and numeric variables is crucial due to the fact that variable type dictates what you can or cannot do with a variable.

  • You can use string functions like concatenating with string variables and taking substrings but not with numeric variables.
  • You can do calculations with the use of numeric variables but not with string variables.

In SPSS, there are no other variable types other than numeric and string. But numeric variables have varied distinct formats that are often confused with variable types.

Numeric Type

Numeric variables contain values that are in number form, like in scientific notation or standard format.

For instance: Counts (like number of free throws given in each game) are a numeric variable containing zero decimal places. Some of the mathematical calculations are allowed when applied for counting variables (like standard and mean deviation), but some statistical processes are excluded (like linear regression).

For instance: Continuous variables that can easily take any number in a range (like blood pressure, weight, height etc.) can be regarded as numeric variables. The researcher is allowed to select as many or few decimal places as they think is required. This type of variable is utilized in calculations, like computing standard and average deviations of heights.

String Variables

Also known as character variables or alphanumeric variables, string variables have values that are considered as text. This infers that the values of string variables may contain symbols, letters or numbers. The string values that are missing may appear blank.