Challenge - 5 Problems
Regression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of simple linear regression coefficients
What is the output of the following MATLAB code that fits a simple linear regression model and displays the coefficients?
MATLAB
x = (1:5)'; y = [2.2; 2.8; 3.6; 4.5; 5.1]; mdl = fitlm(x,y); disp(mdl.Coefficients.Estimate);
Attempts:
2 left
💡 Hint
Look at the linear relationship between x and y and how fitlm estimates intercept and slope.
✗ Incorrect
The fitlm function fits y = beta0 + beta1*x. The estimated intercept is about 1.39 and slope about 0.75 for this data.
❓ data_output
intermediateNumber of observations after removing missing data
Given the dataset with missing values, how many observations remain after removing rows with NaNs using MATLAB?
MATLAB
data = [1 2; NaN 3; 4 NaN; 5 6]; data_clean = rmmissing(data); num_obs = size(data_clean,1);
Attempts:
2 left
💡 Hint
rmmissing removes any row with at least one NaN.
✗ Incorrect
Rows 2 and 3 contain NaNs and are removed. Rows 1 and 4 remain, so 2 observations remain.
❓ visualization
advancedInterpretation of residual plot
You run a linear regression and plot residuals versus fitted values. The plot shows a clear curved pattern. What does this indicate?
Attempts:
2 left
💡 Hint
Look for patterns in residuals to check model assumptions.
✗ Incorrect
A curved pattern in residuals suggests the linear model does not capture nonlinear trends in data.
🧠 Conceptual
advancedEffect of multicollinearity in regression
What is the main problem caused by multicollinearity among predictors in a multiple linear regression model?
Attempts:
2 left
💡 Hint
Think about how correlated predictors affect coefficient estimates.
✗ Incorrect
Multicollinearity makes coefficient estimates sensitive to small data changes, increasing variance and reducing reliability.
🔧 Debug
expertIdentify error in MATLAB code for polynomial regression
What error does the following MATLAB code produce when fitting a polynomial regression model?
MATLAB
x = (1:5)'; y = [2; 4; 6; 8; 10]; X = [x x.^2]; mdl = fitlm(X, y); disp(mdl.Coefficients.Estimate);
Attempts:
2 left
💡 Hint
Check how fitlm accepts predictor inputs.
✗ Incorrect
fitlm accepts numeric matrices for predictors and automatically adds intercept. The code runs without error.
