## Section 4.1 examples # P-value: pchisq(test.stat, df=2, lower=F) ### Example 1: tree data: ## Testing for a difference between p_1 and p_2: # We can specify the number of successes and the sample sizes for each sample: prop.test(c(64,89), n=c(160,261), alternative="two.sided", correct=FALSE) # Or we can equivalently specify the number of successes and # number of failures for each sample: prop.test(matrix(c(64,96,89,172),nrow=2,ncol=2,byrow=TRUE), alternative="two.sided", correct=FALSE) ### Example 2: lighting data: prop.test(matrix(c(714,111,662,154),nrow=2,ncol=2,byrow=TRUE), alternative="greater", correct=FALSE) ### Example 3: bank jobs data: fisher.test(matrix(c(1,9,3,1),nrow=2,ncol=2,byrow=TRUE), alternative="less") ### Example 4: cancer drug study example: ## Enter each 2-by-2 table, separately, by columns: cancer.data <- array(c(10, 12, 1, 1, 9, 11, 0, 1, 8, 7, 0, 3), dim = c(2, 2, 3), dimnames = list( Drug = c("Treatment", "Control"), Response = c("Success", "Failure"), Group = c("1", "2", "3"))) print(cancer.data) ## Mantel-Haenszel test mantelhaen.test(cancer.data, alternative="greater") ## This p-value is based on T4 with a continuity correction