Challenge - 5 Problems
Linear Regression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of simple linear regression coefficients
What is the output of the following R code that fits a linear model and extracts coefficients?
R Programming
data <- data.frame(x = 1:5, y = c(2, 4, 6, 8, 10)) model <- lm(y ~ x, data = data) coef(model)
Attempts:
2 left
💡 Hint
Think about the relationship between y and x in the data.
✗ Incorrect
The data y is exactly 2 times x, so the intercept is 0 and slope is 2.
❓ data_output
intermediate1:30remaining
Number of residuals after fitting lm
After fitting a linear model with 10 observations, how many residuals does the model produce?
R Programming
df <- data.frame(x = 1:10, y = rnorm(10)) model <- lm(y ~ x, data = df) length(residuals(model))
Attempts:
2 left
💡 Hint
Residuals correspond to each observation.
✗ Incorrect
There is one residual per observation, so 10 residuals for 10 data points.
🔧 Debug
advanced2:00remaining
Identify the error in lm formula usage
What error does this R code produce when fitting a linear model?
R Programming
data <- data.frame(x = 1:5, y = c(2, 4, 6, 8, 10)) lm(y = x, data = data)
Attempts:
2 left
💡 Hint
Check the formula argument syntax in lm.
✗ Incorrect
lm expects a formula like y ~ x, not y = x.
🚀 Application
advanced1:30remaining
Interpreting adjusted R-squared
You fit a linear model and get an adjusted R-squared of 0.85. What does this tell you about the model?
Attempts:
2 left
💡 Hint
Adjusted R-squared measures explained variance accounting for predictors.
✗ Incorrect
Adjusted R-squared shows how well the model explains data variance, adjusting for predictors.
🧠 Conceptual
expert2:30remaining
Effect of multicollinearity on lm coefficients
What is the main effect of strong multicollinearity among predictors in a linear regression model?
Attempts:
2 left
💡 Hint
Think about how correlated predictors affect coefficient estimates.
✗ Incorrect
Multicollinearity inflates standard errors and makes coefficients unreliable.