##### Binomial practice problems ##### ### 1 ### 1 - sum(dbinom(0:1, size = 20, prob = 0.05)) ### 2 ### n <- 19 p <- .67 1 - sum(dbinom(0:2, size = n, prob = p)) ##### Normal practice problems ##### ### 1 ### # a # pnorm(.3) # b # 1 - pnorm(0.65) # or pnorm(-0.65) # c # pnorm(0.65) - pnorm(0.3) # or 1 - (pnorm(0.3) + pnorm(-0.65)) # d # pnorm(-0.45) ### 2 ### # a # qnorm(0.2) # b # qnorm(0.80) # c # qnorm(.95) # d # qnorm(.90) ##### Categorical practice problems ##### outcome <- c("S", "D") count <- c(0, 29) gestsurv <- data.frame(outcome, count) binom.test(gestsurv[outcome == "S", 2], sum(count)) # specifies number of successes and number of trials # or binom.test(c(gestsurv[outcome == "S", 2], gestsurv[outcome == "D", 2])) # specifies number of success and number of failures smoking <- read.delim("http://myweb.uiowa.edu/pbreheny/161/data/smoking.txt") binom.test(table(smoking$Survival)) length(which(smoking$Survival == "Alive"))/nrow(smoking)