2025-09-19

Objective

  1. Understand the linear regression model for tree volume.
  2. Explore relationships between Volume, Girth, and Height.
  3. Fit linear models and interpret slope estimates.
  4. Display results using scatterplots and 3D interactive plots.
  5. Display an example of R code for a 3D interactive plot.

Linear Regression Model

To model tree volume (\(Y = \text{Volume}\)) using girth (\(x = \text{Girth}\)), we have:

\[ Y_i = \beta_0 + \beta_1 x_i + \varepsilon_i, \qquad \varepsilon_i \sim N(0,\sigma^2) \] \(\beta_1\) is the expected change in volume as girth increases for each inch.

Estimation and Hypothesis

Least squares estimates minimize \(\sum_i (Y_i - \beta_0 - \beta_1 x_i)^2\).

Hypothesis test for slope: \[ H_0: \beta_1 = 0 \quad \text{vs}\quad H_a: \beta_1 \neq 0 \] t-statistic: \[ t = \frac{\hat\beta_1 - 0}{\text{SE}(\hat\beta_1)}, \quad \text{df} = n-2 \]

Scatterplot of Volume vs Girth

## `geom_smooth()` using formula = 'y ~ x'

Scatterplot of Volume vs Height

## `geom_smooth()` using formula = 'y ~ x'

3D Plot: Volume, Girth, and Height

R Code for 3D Interactive Plot

# 3D interactive scatterplot of Volume, Girth, and Height

library(plotly)
plot_ly(
  data = trees, 
  x = ~Girth,
  y = ~Height, 
  z = ~Volume,
  type = "scatter3d",
  mode = "markers",
  marker = list(size = 6, color = ~Volume, colorscale = "Viridis")
)