%I have commented out the lines of code that will automatically be put into a Sweave document %A Sweave document will have to be saved with a .Rnw extension! %\documentclass{article} %\begin{document} %\SweaveOpts{concordance=TRUE} %This LateX command will leftjustify all the output (not necessary). \begin{flushleft} Name 1\\ STAT 575 Homework \#0\\ \vspace*{2\baselineskip} %or can use %\bigskip Problem from Lab\\ Part A\\ %This is a chunk of R code <<1a, echo=TRUE, eval=TRUE, background="white", include=TRUE, fig=TRUE>>= set.seed(1) bindat <- rbinom(n=10000, size=10, prob=0.8) par(mfrow=c(1,1)) hist(bindat, breaks=seq(2, 10, 1), freq=F) @ Part B\\ %This a new chunk of R code with NO figure <<1b, echo=TRUE, eval=TRUE, background="white", include=TRUE, fig=FALSE>>= 1-pbinom(7, 10, 0.8) @ The probability that Dr. Dribble makes at least 8 out 10 free throws is 0.6778. \pagebreak Part C\\ <<1c, echo=TRUE, eval=TRUE, background="white">>= binom.test(15, 25, 0.4, alternative="greater") hold <- binom.test(15, 25, 0.4, alternative="greater") #the names command is useful! names(hold) hold$conf.int @ The hypothesis testing problem is \\ \smallskip $H_0: p = 0.4$ versus $H_1: p > 0.4$\\ %\vspace*{1\baselineskip} \medskip With a p-value of 0.03439 we reject the null hypothesis. We conclude that there is evidence that the first serve percentage is not 0.4 in favor of the alternative. (This is if a tennis player actually makes 15/25 free throws.) \\ \bigskip You can also interpret the confidence interval! %This LateX command will end the leftjustify all the output. \end{flushleft} %\end{document}