## Median test: # Bidding data: combined.bid.data <- c(199, 210, 228, 232, 245, 246, 246, 249, 255, 210, 225, 225, 235, 240, 250, 251) # Grand median: median(combined.bid.data) # 2-by-c table: bid.2c <- matrix(c(5,3,4,4), nrow=2, ncol=2, byrow=TRUE, dimnames = list(c("> GM", "<= GM"), c("Bidding", "Buy-It-Now"))) # Printing the 2 by c table: as.table(bid.2c) # A quick way to get expected cell counts: expected.counts <- (apply(bid.2c,1,sum) %o% apply(bid.2c,2,sum))/sum(bid.2c) print(expected.counts) # Test statistic: test.stat <- ((16^2)/(8*8))*(5^2 /9 + 3^2/7) - (16*8/8); print(test.stat) # P-value: pchisq(0.254,df=1,lower=F) ############################################## # Corn data: combined.corn.data <- c(83,91,94,89,89,96,91,92,90,91,90,81,83,84,83,88,91,89,84,101,100,91,93,96,95,94,78,82,81,77,79,81,80,81) # Grand median: median(combined.corn.data) # 2-by-c table: corn.2c <- matrix(c(6,3,7,0,3,7,0,8), nrow=2, ncol=4, byrow=TRUE, dimnames = list(c("> GM", "<= GM"), c("1", "2", "3", "4"))) # Printing the 2 by c table: as.table(corn.2c) # A quick way to get expected cell counts: expected.counts <- (apply(corn.2c,1,sum) %o% apply(corn.2c,2,sum))/sum(corn.2c) print(expected.counts) # Test statistic: test.stat <- ((34^2)/(16*18))*(6^2 /9 + 3^2/10 + 7^2/7 + 0^2/8) - (34*16/18); print(test.stat) # P-value: pchisq(17.54,df=3,lower=F)