Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. totals <- c(195, 134, 38)
  2. stems <- c(22,16,9)
  3. group_stem_counts <- matrix(c(stems, totals-stems),ncol=3,byrow=TRUE)
  4. rownames(group_stem_counts) <- c("stem", "non-stem")
  5. colnames(group_stem_counts) <- c("Group One","Group Two","Group Three")
  6. group_stem_counts
  7. # Group One Group Two Group Three
  8. # stem 22 16 9
  9. # non-stem 173 118 29
  10.  
  11. chisq.test(group_stem_counts)
  12. #
  13. # Pearson's Chi-squared test
  14. #
  15. # data: group_stem_counts
  16. # X-squared = 4.5225, df = 2, p-value = 0.1042
  17. #
  18. # Warning message:
  19. # In chisq.test(group_stem_counts) :
  20. # Chi-squared approximation may be incorrect
  21.  
  22. chisq.test(group_stem_counts)$expected
  23. # Group One Group Two Group Three
  24. # stem 24.97275 17.16076 4.866485
  25. # non-stem 170.02725 116.83924 33.133515
  26. # Warning message:
  27. # In chisq.test(group_stem_counts) :
  28. # Chi-squared approximation may be incorrect
  29.  
  30. chisq.test(group_stem_counts, simulate.p.value=TRUE)
  31. #
  32. # Pearson's Chi-squared test with simulated p-value (based on 2000
  33. # replicates)
  34. #
  35. # data: group_stem_counts
  36. # X-squared = 4.5225, df = NA, p-value = 0.1184
  37.  
  38. > p=c(.1,.2,.3,.4)
  39. > x=c(3,5,16,10)
  40. > chisq.test(x,p=p,simulate.p.value=TRUE,B=10000)
  41.  
  42. Chi-squared test for given probabilities with simulated p-value (based on 10000
  43. replicates)
  44.  
  45. data: x
  46. X-squared = 4.7745, df = NA, p-value = 0.1904
  47.  
  48. > chisq.test(x,p=p,simulate.p.value=TRUE,B=10000)
  49.  
  50. Chi-squared test for given probabilities with simulated p-value (based on 10000
  51. replicates)
  52.  
  53. data: x
  54. X-squared = 4.7745, df = NA, p-value = 0.1922
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement