Section 6.2 Chi-Squared Test
The first hypothesis testing covered in this book is the chi-squared test, commonly called the one-sample chi-square. It is frequently employed to compare the proportion of cases from a sample with either hypothesized values or those previously obtained from a comparison population. In the data file, only one categorical variable and a designated proportion against which to evaluate the observed frequency are required. This test may assess whether no difference exists in the proportion within each category (e.g., 50%/50%) or against a specific proportion derived from a previous study.
For instance, 44 male respondents used credit cards, while 62 female respondents used credit cards for online purchases in our example. From this tabulation, we may conclude that more female respondents use credit cards for online purchases than their male counterparts. There is a difference in the usage of credit cards for online purchases between male and female groups. However, we have no evidence to determine whether this difference is statistically significant or by accident. Thatβs why we conduct a hypothesis test to confirm our findings with statistical evidence. Below, we will evaluate the usage of credit cards for online purchases in the past 12 months between men and women using the NCVS data we used in the last chapter.
Subsection 6.2.1 NHST Steps for Chi-Squared Test
Subsection 6.2.1.1 Step 1: Formulate the Null and Alternative Hypotheses
The first step in conducting the chi-squared test is to write the null and alternative hypotheses.
-
\(H_0\text{:}\) The usage of credit cards for online purchases in the past 12 months is the same across men and women.
-
\(H_A\text{:}\) The usage of credit cards for online purchases in the past 12 months is not the same across men and women.
Subsection 6.2.1.2 Step 2: Calculate the Test Statistic
The test statistic to use when examining a relationship between two categorical variables is the chi-squared statistic. First, you will need to download the revised data from the 2016 NCVS from the shared Google Drive folder. Then, you will need to load the data using the following syntax.
library(haven)
rNCVS2016 <- read_dta("rNCVS2016.dta")
View(rNCVS2016)
We will perform a chi-squared test on a contingency table using R. The variable
male was coded as 0 for women and 1 for men. The PayCred variable represents whether the respondent used credit cards for online purchases in the past 12 months. Those who used it were coded as 1, and those who did not were coded as 0.
chisq.test(x = rNCVS2016$Male, y = rNCVS2016$PayCred)
The test statistic was \(\chi^2 = 0.54045\text{.}\)
Subsection 6.2.1.3 Step 3: Determine the Probability (P-Value)
The probability of observing a chi-squared value of 0.54 in our sample, assuming no association between men and women in the population in using credit cards for online purchases in the past 12 months, is calculated to be 0.4622, indicating a p-value greater than 0.05.
Subsection 6.2.1.4 Step 4: If the P-Value Is Very Small, Typically Less Than 5%, Reject the Null Hypothesis
Step 4 is not relevant in this situation.
Subsection 6.2.1.5 Step 5: If the P-Value Is Not Small, Typically 5% or Greater, Retain the Null Hypothesis
The probability that the null hypothesis, stating βThe usage of credit cards for online purchases in the past 12 months is the same across men and women,β holds true in the population, based on our sample data, is calculated to be 0.4622, indicating a p-value greater than 0.05. This relatively high probability suggests that the null hypothesis is likely true and should not be rejected.
