February 08, 2026

.gdbar { width: 200px !important; height: 100px !important; }

Dataset Orange

data(Orange)
head(Orange)
  Tree  age circumference
1    1  118            30
2    1  484            58
3    1  664            87
4    1 1004           115
5    1 1231           120
6    1 1372           142

Orange: Age (in days from 12/31/68) vs. Circumference

Code of Age vs Circumference

x <- Orange$age
y <- Orange$circumference
model <- lm(y~x, data = Orange)


orangefig <- plot_ly(Orange, x = ~age, y = ~circumference, z = ~Tree) %>%
  add_markers(color = ~Tree)

orangefig

Analysis of variance

Latex Syntax for Analysis of Variance

model: \(\sum_{i=1}^n(y_i - \bar{y})^2 = \sum_{i=1}^n(\hat{y}_i - \bar{y})^2 + \sum_{i=1}^n(y_i - \hat{y}_i)^2\)

Linear Regression of Tree Growth

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

Code for Linear Regression

og <- ggplot(Orange, aes(x = age, y = circumference)) + geom_point(aes(color = Tree))
og + geom_smooth(method="lm", se=FALSE, color="coral")

Latex Syntax for Linear Regression

\(circumference = \beta_0 + \beta_1\cdot age + \varepsilon\), where \(\varepsilon \sim\mathcal{N}(\mu=0; \,\,\sigma^2)\)

\(\displaystyle MSE = {SSE \over n-2} = {1\over n-2} \sum_{i=1}^n (y_i - \hat{y}_i)^2\)

Barplot of Average Circumference by Age