Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- totals <- c(195, 134, 38)
- stems <- c(22,16,9)
- group_stem_counts <- matrix(c(stems, totals-stems),ncol=3,byrow=TRUE)
- rownames(group_stem_counts) <- c("stem", "non-stem")
- colnames(group_stem_counts) <- c("Group One","Group Two","Group Three")
- group_stem_counts
- # Group One Group Two Group Three
- # stem 22 16 9
- # non-stem 173 118 29
- chisq.test(group_stem_counts)
- #
- # Pearson's Chi-squared test
- #
- # data: group_stem_counts
- # X-squared = 4.5225, df = 2, p-value = 0.1042
- #
- # Warning message:
- # In chisq.test(group_stem_counts) :
- # Chi-squared approximation may be incorrect
- chisq.test(group_stem_counts)$expected
- # Group One Group Two Group Three
- # stem 24.97275 17.16076 4.866485
- # non-stem 170.02725 116.83924 33.133515
- # Warning message:
- # In chisq.test(group_stem_counts) :
- # Chi-squared approximation may be incorrect
- chisq.test(group_stem_counts, simulate.p.value=TRUE)
- #
- # Pearson's Chi-squared test with simulated p-value (based on 2000
- # replicates)
- #
- # data: group_stem_counts
- # X-squared = 4.5225, df = NA, p-value = 0.1184
- > p=c(.1,.2,.3,.4)
- > x=c(3,5,16,10)
- > chisq.test(x,p=p,simulate.p.value=TRUE,B=10000)
- Chi-squared test for given probabilities with simulated p-value (based on 10000
- replicates)
- data: x
- X-squared = 4.7745, df = NA, p-value = 0.1904
- > chisq.test(x,p=p,simulate.p.value=TRUE,B=10000)
- Chi-squared test for given probabilities with simulated p-value (based on 10000
- replicates)
- data: x
- X-squared = 4.7745, df = NA, p-value = 0.1922
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement