
```{r}

prop<-read.table("https://math.dartmouth.edu/~m50f17/propellant.csv", header=T, sep=",")
summary(prop)


```

```{r}

age<-prop$Age 
shearS<-prop$ShearS
plot(age,shearS)
fitted<-lm(formula= shearS ~ age) 
abline(fitted$coef, lwd=2, col='blue')
N<-length(age) 
yHat <- predict(fitted)

```

### Lets calculate/plot the above without using builtin function lm

```{r}
  

Sxx<-sum((age-mean(age))^2)
Sxy<-sum((age-mean(age))*shearS)
beta1Hat<-Sxy/Sxx
beta0Hat<-mean(shearS)-Sxy/Sxx*mean(age)
plot(age,shearS)
abline(c(beta0Hat,beta1Hat), lwd=2, col='blue')


```

### Verify analysis of variance identity

```{r}

yBar <- mean (shearS)
yHat <- fitted$fitted.values  ; 

SSt <- sum((shearS - yBar)^2);
SSr <- sum((yHat - yBar)^2);
SSres <- sum((shearS - yHat)^2);

SSt - (SSr + SSres)
SSt

```


### t distribution : Books notation vs R functions

```{r}

alpha = 0.05 ; 

tQuantile_975 <- qt( 1 - 0.05/2 , 18) 
tQuantile_975

tQuantile_975 <- qt( 0.975 , 18) 
tQuantile_975

tQuantile_025 <- qt( 0.025 , 18) 
tQuantile_025

pt(tQuantile_025 , 18 )

pt(tQuantile_975 , 18 )


```


### F distribution : Books notation vs R functions

```{r}

alpha = 0.05 ; 

fQuantile_95 <- qf(0.95,1,18) ; 
fQuantile_95

fQuantile_05 <- qf(0.05,1,18) ; 
fQuantile_05


pf(fQuantile_95 ,1,18) 

pf(fQuantile_05 ,1,18) 


```
