Predicting Movie Rating from Length
Randy Mattoka
March 7, 2026
2026-03-07
Randy Mattoka
March 7, 2026
movies dataset from ggplot2movies.\[ Y = \beta_0 + \beta_1 X + \varepsilon \]
Where:
\[ \hat{\beta}_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})} {\sum (x_i - \bar{x})^2} \]
\[ \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x} \]
These minimize: \[ \sum (y_i - \hat{y}_i)^2 \]
lm1 = lm(rating ~ length, data = movies) b0 =coef(lm1)[1] b1 = coef(lm1)[2] r2 = summary(lm1)$r.squared p = summary(lm1)$coefficients[2,4] round(c(Intercept=b0, Slope=b1, R2=r2, p_value=p), 6)
Intercept.(Intercept) Slope.length R2
6.021471 -0.001076 0.000945
p_value
0.000000
`geom_smooth()` using formula = 'y ~ x'
Conclusion: Length has a statistically significant but practically negligible effect on rating (R² ≈ 0.0009).