library(readxl)
library(ggplot2)
library(rcompanion)
luigi<- read_excel("D:/Vedant Work/SLU/Spring Sem (Jan to May 2026)/Applied Analytics/Assignment 5/luigi.xlsx")
colnames(luigi)
## [1] "studentid" "studenttype" "petownership"
deploying table for refrence
tab<- table(luigi$studenttype, luigi$petownership)
tab
##
## No Yes
## Domestic 27 25
## International 23 25
displaying bar chart for clarity
ggplot(luigi,aes(x=studenttype,fill=petownership))+
geom_bar(position="dodge")+
labs(
x="studenttype",
y="Frequency",
title="petownership by studenttype"
)+
theme(
text = element_text(size = 14),
axis.title = element_text(size = 14),
axis.text = element_text(size = 14),
plot.title = element_text(size = 14),
legend.position = "none"
)
chisq.test(tab)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: tab
## X-squared = 0.040064, df = 1, p-value = 0.8414
The Chi-Square Test of Independence was conducted to determine
whether there is a relationship between student type and pet ownership.
The results indicated that there was no statistically
significant association between student type and pet
ownership,
χ²(1) = 0.040, p = 0.8414. Since the p-value is greater than 0.05, we
fail to reject the null hypothesis. Therefore, student type and pet
ownership appear to be independent. Because the result was not
statistically significant, Cramer’s V was not calculated.