ahl— title: “STAT 516 hw 1” author: “David Burgess” format: pdf # format: html —

# Ch 4 Ex 8

t.test(Blood_Pressure, mu=129, alternative = "greater")

Since p=.1708 which is greater than 0.01, 
we fail to reject the null hypothesis. We don't have enough evidence to say the blood pressure of a normal male exceeds 129.

# Ch 4 Ex 19

ahl<-c(2.50, 2.20, 1.60, 1.30, 1.20, 1.60, 2.20, 2.20, 2.60, 1.00, 1.50, 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(ahl)
lo<-mean(Ahl)-qt(1-alpha/2,n-1)*sd(Ahl)/sqrt(n)
up<-mean(ahl)+qt(1-alpha/2,n-1)*sd(ahl)/sqrt(n)
95% CI: (1.596, 2.154)
We are 95% confident that the true mean half-life of Amikacin is inbetween 1.596 and 2.154

# Ch 4 Ex 20

ahl<-c(2.50, 2.20, 1.60, 1.30, 1.20, 1.60, 2.20, 2.20, 2.60, 1.00, 1.50, 3.15, 1.44, 1.26, 1.98, 1.98, 1.87, 2.31, 1.40, 2.48, 2.80, 0.69)
alpha1<-.10
n<-length(ahl)
chiup<- (n-1)*var(ahl)/qchisq(1-alpha1/2, n-1)
chiup1<-(n-1)*var(ahl)/qchisq(alpha1/2, n-1)

90% CI: (.255, .719)
We are 90% confidence that the true variance of the half life of Amikacin is inbetween .255 and .719). 

# Ch 7 Ex 7

Tavg<-c(77.5, 80.0, 78.0, 78.5, 77.5, 83.0, 83.5, 81.5, 75.5, 69.5, 70.0, 73.5, 77.5, 79.0, 80.0, 79.0, 76.0, 76.0, 75.5, 79.5, 78.5, 82.0, 71.5, 70.0, 68.0, 66.5, 69.0, 70.5, 63.0, 64.0, 64.5, 65.0, 66.5, 67.0, 66.5, 67.5, 75.0, 75.5, 71.5, 63.0, 60.0, 64.0, 62.5, 63.5, 73.5, 68.0, 77.5)

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)

lm1<-lm(Kwh~Tavg)
summary(lm1)

Call:
lm(formula = Kwh ~ Tavg)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.150  -3.647  -0.152   3.348  23.852 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) -97.9239    13.8616  -7.064 8.18e-09 ***
Tavg          2.0010     0.1906  10.498 1.11e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 8.388 on 45 degrees of freedom
Multiple R-squared:  0.7101,    Adjusted R-squared:  0.7036 
F-statistic: 110.2 on 1 and 45 DF,  p-value: 1.111e-13
plot(Kwh~Tavg, ylab="Power Consumption", xlab="Average Temperature")

Kwh= 2.0010*(Tavg)-97.9239
beta_0= -97.9239
beta_1= 2.0010
With the p value being close to 0 and less than 0.05, we can reject the null hypothesis (Beta_1=0). We can conclude that there is evidence of a linear relationship between Kwh and Tavg. ```

::: {.cell}

```{.r .cell-code}
plot(lm1, which=1)

:::

No clear pattern made in residuals v. Fitted plot.