========================================
CHI-SQUARE TEST OF INDEPENDENCE OVERVIEW
========================================
PURPOSE
To test if there is an association between two categorical
variables.
NOTES
Normality does not apply to Chi-Square tests because data is only
categorical.
==========
HYPOTHESES
==========
NULL HYPOTHESIS
There is no association between the two categorical variables.
ALTERNATE HYPOTHESIS
There is an association between the two categorical variables.
======================
IMPORT EXCEL FILE CODE
======================
PURPOSE OF THIS CODE
Imports your Excel dataset automatically into R Studio.
You need to import your dataset every time you want to analyze your
data in R Studio.
INSTALL REQUIRED PACKAGE
The package only needs to be installed once.
The code for this task is provided below. Remove the hashtag below
to convert the note into code.
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("readxl")
## Installing package into 'C:/Users/manit/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'readxl' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\manit\AppData\Local\Temp\RtmpmkBKDy\downloaded_packages
LOAD THE PACKAGE
You must always reload the package you want to use.
The code for this task is provided below. Remove the hashtag below
to convert the note into code.
library(readxl)
IMPORT THE EXCEL FILE INTO R STUDIO
Download the Excel file from One Drive and save it to your
desktop.
Right-click the Excel file and click “Copy as path” from the
menu.
In R Studio, replace the example path below with your actual
path.
Replace backslashes with forward slashes / or double them //:
✘ WRONG “C:.xlsx”
✔ CORRECT “C:/Users/Joseph/Desktop/mydata.xlsx”
✔ CORRECT “C:\Users\Joseph\Desktop\mydata.xlsx”
Replace “dataset” with the name of your excel data (without the
.xlsx)
An example of the code for this task is provided below.
You can edit the code below and remove the hashtag to use the code
below.
dataset <- read_excel("C:/Users/manit/Downloads/RQ2.xlsx")
=========================
VISUALLY DISPLAY THE DATA
=========================
PURPOSE
Visually display the data.
A frequency table can be used instead of a bar graph to visually
display the data.
CREATE A FREQUENCY TABLE
Also called a “contingency table” for Chi-Square Test of
Independence.
Replace “dataset” with the name of your dataset (without the
.xlsx)
Replace “Variable1” with the R code name of your first variable
Replace “Variable2” with the R code name of your second
variable
Remove the hashtag to use the code.
contingencytable <- table(dataset$Parent, dataset$Preferred_Design)
print(contingencytable)
##
## A B
## Father 21 29
## Mother 31 19
====================================
CHI-SQUARE TEST OF INDEPENDENCE CODE
====================================
PURPOSE
Determine if the null or alternate hypothesis was supported.
CONDUCT THE TEST
Do NOT edit the code.
DETERMINE STATISTICAL SIGNIFICANCE
If results were statistically significant (p < .05), continue to
the effect size section below.
If results were NOT statistically significant (p > .05), do NOT
calculate the effect size.
Instead, skip to the reporting section below.
NOTE: Getting results that are not statistically significant does
NOT mean you switch to a different test.
==========================
RESEARCH REPORT ON RESULTS
==========================
A Chi-Square Test of Independence was conducted to examine the
association between parent (Father, mother) and design preference
(Design A, design B) among 100 participants. There was not statistically
significant association between parent and design preference, χ²(1, N =
100) = 3.2452, 3.2452 (p > .05). Hence effect size is un-needed