Advertisement
Guest User

Untitled

a guest
May 29th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. # --------------------------------------------------------------------------------------------------------------
  2. # --------------------------------------------------------------------------------------------------------------
  3. # Chi-Sqaure Test for Independence
  4. # --------------------------------------------------------------------------------------------------------------
  5. # --------------------------------------------------------------------------------------------------------------
  6.  
  7. library(MASS)
  8. data(survey);survey
  9. Survey_CT <- table(survey$Smoke,survey$Exer)
  10.  
  11. # --------------------------------------------------------------------------------------------------------------
  12. # Hypothesis H_0 : Students smoking habit is Independent of their Exercise level
  13. # Hypothesis H_1 : Students smoking habit is not Independent of their Exercise level
  14. # --------------------------------------------------------------------------------------------------------------
  15.  
  16. # --------------------------------------------------------------------------------------------------------------
  17. # Solution : Chi-Squared test function
  18. # --------------------------------------------------------------------------------------------------------------
  19.  
  20. chisq.test(Survey_CT)
  21.  
  22. # --------------------------------------------------------------------------------------------------------------
  23. # Conclusion/Interpretation : Since P--value is greater than 0.05, we fail to reject NH. We conclude
  24. # that, students smoking habit is not Independent of their Exercise level
  25. # --------------------------------------------------------------------------------------------------------------
  26. # --------------------------------------------------------------------------------------------------------------
  27. # ----------------- END -------------- Chi-Sqaure Test for Independence -------------- END ---------------------
  28. # --------------------------------------------------------------------------------------------------------------
  29. # --------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement