Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # --------------------------------------------------------------------------------------------------------------
- # --------------------------------------------------------------------------------------------------------------
- # Chi-Sqaure Test for Independence
- # --------------------------------------------------------------------------------------------------------------
- # --------------------------------------------------------------------------------------------------------------
- library(MASS)
- data(survey);survey
- Survey_CT <- table(survey$Smoke,survey$Exer)
- # --------------------------------------------------------------------------------------------------------------
- # Hypothesis H_0 : Students smoking habit is Independent of their Exercise level
- # Hypothesis H_1 : Students smoking habit is not Independent of their Exercise level
- # --------------------------------------------------------------------------------------------------------------
- # --------------------------------------------------------------------------------------------------------------
- # Solution : Chi-Squared test function
- # --------------------------------------------------------------------------------------------------------------
- chisq.test(Survey_CT)
- # --------------------------------------------------------------------------------------------------------------
- # Conclusion/Interpretation : Since P--value is greater than 0.05, we fail to reject NH. We conclude
- # that, students smoking habit is not Independent of their Exercise level
- # --------------------------------------------------------------------------------------------------------------
- # --------------------------------------------------------------------------------------------------------------
- # ----------------- END -------------- Chi-Sqaure Test for Independence -------------- END ---------------------
- # --------------------------------------------------------------------------------------------------------------
- # --------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement