# STAT_515_Lec_18 load(url("https://people.stat.sc.edu/gregorkb/data/beryllium.Rdata")) Y <- beryllium$logN_Be x <- beryllium$Teff plot(Y~x) # correlation rxY <- cor(x,Y) sY <- sd(Y) sx <- sd(x) Ybar <- mean(Y) xbar <- mean(x) b1hat <- rxY * sY / sx b0hat <- Ybar - b1hat * xbar abline(b0hat,b1hat) # how to fit the simple linear regression model in R lm_out <- lm(Y ~ x) # lm() is for "linear model" lm_out confint(lm_out,level=.99) summary(lm_out) # check normality of responses around the line: plot(lm_out, which = 2) # for linearity / constant variance plot(lm_out, which = 1)