Validate regression assumptions with residuals, fitted vs observed plots, and influence measures—plot(fit) generates diagnostic panels locally.
Residuals
fit <- lm(y ~ x, data = df)
print(residuals(fit))
print(fitted(fit))
Diagnostic plots (local)
# plot(fit) # four-panel diagnostics when run locally
Look for non-linearity, heteroscedasticity, and influential points—do not ship models without checks.
Important interview questions and answers
- Q: What are residuals?
A: Observed minus fitted values—should look randomly scattered for linear models. - Q: plot(fit) panels?
A: Standard R diagnostic plots: residuals vs fitted, Q-Q, scale-location, leverage.
Self-check
- How compute residuals from fit?
- Why inspect Q-Q plot?
Tip: Run plot(fit) locally before trusting coefficients in a report.
Interview prep
- Residual plots?
Check patterns—curves suggest non-linearity; funnel shapes suggest heteroscedasticity.