--- title: "STAT 516 HW1" author: "redacted" # format: pdf format: html --- # Ch.4 ## 8 ```{r} bp<-c(115,134,131,143,130,154,119,137,155,130,110,138) t.test(bp, mu=129, alternative="greater") ``` Since... $$p-value = 0.1708 > \alpha = 0.01$$ ...We fail to reject the null hypothesis that the mean blood pressure (for adult males in this community) is normal (129). We fail to find evidence that adult males from this community have a higher blood pressure. ## 19 ```{r} Am<-c(2.5,2.2,1.6,1.3,1.2,1.6,2.2,2.2,2.6,1,1.5,3.15,1.44,1.26,1.98,1.98,1.87,2.31,1.40,2.48,2.80,0.69) alpha<-0.05 n<-length(Am) lo<-mean(Am)-qt(1-alpha/2,n-1)*sd(Am)/sqrt(n) up<-mean(Am)+qt(1-alpha/2,n-1)*sd(Am)/sqrt(n) lo up t.test(Am) ``` As shown by both methods of calculation above, the 95% confidence interval for the true mean half-life of Amikacin is (1.596164,2.154745). We are 95% confident that the true mean half-life of Amikacin falls between 1.596164 and 2.154745. ## 20 ```{r} Am<-c(2.5,2.2,1.6,1.3,1.2,1.6,2.2,2.2,2.6,1,1.5,3.15,1.44,1.26,1.98,1.98,1.87,2.31,1.40,2.48,2.80,0.69) alpha2<-0.10 n<-length(Am) losgs<-(n-1)*var(Am)/qchisq(1-alpha2/2, n-1) upsgs<-(n-1)*var(Am)/qchisq(alpha2/2, n-1) losgs upsgs ``` As shown above, the 90% confidence interval on the variance of the half-life of Amikacin is (0.2550535,0.718879). We are 90% confident that the true variance of the half-life of Amikacin falls between 0.2550535 and 0.718879. # Ch.5 ## 10 ### (a) ```{r} diff<-c(3,0,5,1,2,2) t.test(diff,mu=0,alternative="greater") ``` Since... $$p-value = 0.01371 < \alpha = 0.05$$ ...We reject the null hypothesis that there is no difference, on average, between the scores before and after the seminar. We find evidence to suggest that employees believe their knowledge has improved after the seminar (in favor of a positive difference). ### (b) This might introduce nonresponse bias into the study. Leaving these 6 employees who did not return the follow-up rating out of our analysis could undermine the strength of our conclusion. For instance, those 6 employees may have felt that their scores were the same, or maybe even slightly worse, after the seminar. The inclusion of this data could have altered our results, and we may not have found evidence that employees felt their knowledge improved after the seminar. # Ch. 7 ## 7 ### (a) ```{r} Kwh<-c(45,73,43,61,52,56,70,69,53,51,39,55,55,57,68,73,57,51,55,56,72,73,69,38,50,37,43,42,25,31,31,32,35,32,34,35,41,51,34,19,19,30,23,35,29,55,56) Tavg<-c(77.5,80,78,78.5,77.5, 83, 83.5, 81.5, 75.5, 69.5, 70, 73.5, 77.5, 79, 80, 79, 76, 76, 75.5, 79.5, 78.5, 82, 71.5, 70, 68, 66.5, 69, 70.5, 63, 64, 64.5, 65, 66.5, 67, 66.5, 67.5, 75, 75.5, 71.5, 63, 60, 64, 62.5, 63.5, 73.5, 68, 77.5) plot(Kwh~Tavg, ylab="Power Consumption", xlab="Average Temperature") ``` ### (b) ```{r} lm1<-lm(Kwh~Tavg) summary(lm1) ``` As shown above... $$\hat \beta_0 = -97.9239$$ $$\hat \beta_1 = 2.0010$$ Additionally, since p is approximately 0, and less than an alpha level of 0.05, we reject the null hypothesis that there is no relationship between average temperature and power consumption (that the slope is 0). We find evidence that there is a relationship between average temperature and power consumption (the slope does not equal 0). ### (c) ```{r} plot(lm1,which=1) ``` The above plot looks pretty good, aside from the outliers (the variance seems to be fairly constant among all values of the covariate (moving left to right); the plot seems to be randomly scattered (no apparent curvature). ```{r} plot(lm1,which=2) ``` The Q-Q plot seems to be a bit problematic towards the ends, although the middle does seem to be pretty linear.