These slides demonstrates simple linear regression using the built in trees data set in R.
I will analyze how a tree, its circumference in inches, relates to its volume in cubic feet.
The slides and graphs used to visualize, model, and interpret this linear relationship using ggplot2 and plotly. The model we’ll explore has the form: \[
\text{Volume}=\beta_0+\beta_1\cdot\text{Girth}+\varepsilon,\quad\mathcal{N}(0,\sigma^2)
\]
My plan is to estimate \(\beta_0\) and\(\beta_1\) using least squares: \[ S(\beta_0,\beta_1)=\sum_{i=1}^n(\text{Volume}-\beta_0-\beta_1\text{Girth})^2 \]
Each observation should represents a tree, with its Girth, Height, and Volume, with a focus on Girth and Volume for estimation.
## Warning: package 'ggplot2' was built under R version 4.5.2
## Warning: package 'plotly' was built under R version 4.5.2
## ## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2': ## ## last_plot
## The following object is masked from 'package:stats': ## ## filter
## The following object is masked from 'package:graphics': ## ## layout
## Girth Height Volume ## 1 8.3 70 10.3 ## 2 8.6 65 10.3 ## 3 8.8 63 10.2 ## 4 10.5 72 16.4 ## 5 10.7 81 18.8 ## 6 10.8 83 19.7
## Girth Height Volume ## Min. : 8.30 Min. :63 Min. :10.20 ## 1st Qu.:11.05 1st Qu.:72 1st Qu.:19.40 ## Median :12.90 Median :76 Median :24.20 ## Mean :13.25 Mean :76 Mean :30.17 ## 3rd Qu.:15.25 3rd Qu.:80 3rd Qu.:37.30 ## Max. :20.60 Max. :87 Max. :77.00