## ----setup, include=FALSE, cache=FALSE------------------------------------------------------------------------------------------------------------------------------------------- require(knitr) is.key <- TRUE # set global chunk options opts_chunk$set(echo=TRUE,eval=TRUE,fig.path='figs/', fig.align='center', fig.show='hold') options(formatR.arrow=TRUE, width=90) ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- pnorm(95,mean=100,sd=2.236,lower.tail=TRUE) # prob of getting a score <= 95 pnorm(105,mean=100,sd=2.236,lower.tail=FALSE) # prob of getting a score >= 105 0.01267143+0.01267143 # prob of getting a score <= 95 OR >= 105 ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # the probability of getting a score <= 95.6 is 0.025... qnorm(.025,mean=100,sd=2.236,lower.tail=TRUE) # qnorm... not pnorm pnorm(95.61752,mean=100,sd=2.236,lower.tail=TRUE) # the probability of getting a score >= 104.38 is 0.025... pnorm(104.3825,mean=100,sd=2.236,lower.tail=FALSE) 0.02499999 + 0.02499946 # the JOINT probability of getting a score <=95.6 OR >=104.38 ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- my.scores <- c(96, 94, 102, 86, 100, 92, 105, 86, 111, 82, 96, 79, 79, 85, 99, 97, 105, 98, 94, 73) t.test(x=my.scores,alternative="two.sided", mu=100) ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- t.test(x=my.scores,alternative="less", mu=100) ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- t.test(x=my.scores,alternative="greater", mu=100) ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- power.t.test(n=20,delta=5,sd=10,sig.level=0.05,type="one.sample",alternative="two.sided") ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- power.t.test(n=20,delta=5,sd=10,sig.level=0.05,type="one.sample",alternative="one.sided") ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- sample.A <- c(95, 92, 93, 96, 98, 99) sample.B <- c(101, 99, 106, 100, 98, 111) t.test(x=sample.A,y=sample.B,alternative="two.sided", var.equal=TRUE) ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- t.test(x=sample.A,y=sample.B,alternative="two.sided") ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- t.test(x=sample.A,y=sample.B,paired=TRUE)