Homework 4

oxygen<-read.csv("https://raw.githubusercontent.com/kitadasmalley/sp21_MATH376LMT/main/data/oxygenPurity.csv", header = TRUE)
# Explanatory : Percent Hydrocarbon
x<-oxygen$hydro
# Response: Purity of Oxygen
y<-oxygen$purity

a)

Finding the equation of the line from scratch and check with lm().

b1 = sum((x - mean(x))*y)/sum((x - mean(x))^2)
b0 = mean(y) - b1*mean(x)
b1
## [1] 11.80103
b0
## [1] 77.86328
lm(y~x)
## 
## Call:
## lm(formula = y ~ x)
## 
## Coefficients:
## (Intercept)            x  
##       77.86        11.80