--- title: "A first SLR model fit to data from the class" output: pdf_document --- Here's the SLR model that we are going to fit using data from our class: $$\mu\{Height|Pets\} =\beta_0 + \beta_1\times Pets$$ After randomly selecting 3 students from class (with name s S, Z and E), we asked them how many pets they had growing up (Pets) and how tall (inches) they are right now. Here's the R code: ```{r} Pets = c(5,3,4) Hts =c(65,66,67) ID=c("S","Z","E") m = lm(Hts ~ Pets) summary(m) ``` The slope for the best fit line is $$\hat\beta_1=r\times\frac{s_y}{s_x}$$ Let's check this formula with what R reported above: ```{r} # Check R cor(Pets,Hts) sd(Pets) sd(Hts) # \hat \beta_1 sd(Hts)/sd(Pets)*cor(Pets,Hts) # \hat \beta_0 mean(Hts)-mean(Pets)*(-.5) ``` Let's generate a scatterplot and overlay the regression line ```{r} # Let's add this line to the scatterplot plot(Pets,Hts) abline(68,-1/2) ```