April 13, 2026

Dataset trees

data(trees)
head(trees)
  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

The Statistical Model

To understand the relationship between a tree’s girth and its volume, we use a simple linear regression model.

\[\hat{y} = \hat{\beta}_0 + \hat{\beta}_1 x\]

Linear Regression

The Predicted Volume should equal the intercept plus the Slope times Girth

\[\widehat{\text{Volume}} = \text{Intercept} + (\text{Slope}*\text{Girth})\]

Linear Regression in R

# Fit the linear model
model <- lm(Volume ~ Girth, data = trees)

# Display coefficients
summary(model)$coefficients
              Estimate Std. Error   t value     Pr(>|t|)
(Intercept) -36.943459   3.365145 -10.97827 7.621449e-12
Girth         5.065856   0.247377  20.47829 8.644334e-19

Data Visualization #1 (ggplot2)

Data Visualization #2 (ggplot2)

Data Visualization #3 (plotly)