`geom_smooth()` using formula = 'y ~ x'
2025-06-03
`geom_smooth()` using formula = 'y ~ x'
A method for modeling relationships between variables
Possible to predict a variable based on one or more other variables
A method to understand the relationship between two variables
A predictive (x-axis) variable and a response variable (y-axis)
Below we have a table containing information about orange trees
| age | circumference |
|---|---|
| 118 | 30 |
| 484 | 58 |
| 664 | 87 |
| 1004 | 115 |
| 1231 | 120 |
| 1372 | 142 |
The figure shows a scatter plot of age vs. circumference
cor(Orange$age, Orange$circumference)
[1] 0.9135189
LinMod <- lm(Orange$circumference ~ Orange$age)
\[Y={\beta_0 + \beta_1 \cdot X + \epsilon}\] \(\cdot\) Y is our response variable
\(\cdot\) X is our predictive variable
\(\cdot\) \(\beta_0\) is our intercept
\(\cdot\) \(\beta_1\) is our slope
\(\cdot\) \(\epsilon\) is our error term
Our equation then becomes
\[Y={17.4 + 0.11 \cdot X + \epsilon}\] Which we can use to calculate values outside of the data range
`geom_smooth()` using formula = 'y ~ x'