Unit 3 Programming Assignment.
We are asked to solve problems using RScript. I have summarized the results of my analysis
below. I am also attaching the RScript ran, just in case there are any questions.
– Rscript
# Plot + regression line
plot(Boston$lstat, Boston$medv,
xlab = "lstat (% lower status of the population)",
ylab = "medv (median home value)")
abline([Link], lwd = 2)
This scatterplot demonstrates negative relationship between medv and lstat. As the percentage of
lower income households increases, median home values decrease. The regression line indicates
a lowering linear trend. Some curvature suggests possible non-linearity in the negative
relationship.
# Diagnostic plots (4 plots)
par(mfrow = c(2, 2))
plot([Link])
Residuals versus Fitted plot indicates a slight curved pattern rather than simply random scatter
suggesting mild non-linearity in relationship between lstat and medv.
Q-Q plot indicates residuals are normally distributed.
Scale-Location plot seems to show that the residual variance is not constant across fitted values.
Residuals versus Leverage shows a few high-leverage points, but no extreme points.
This pattern above shows that the linear model is missing curvature.
The plot of studentized residuals versus fitted values show a pattern similar to the raw residual
plot that was previously rendered. There are no extreme studentized residuals seen so no outliers
influencing model.
The plot shows that most observations have low leverage values. While there might be a small
number of data points that show some higher leverage, none appear as extreme outliers.
Therefore, no data seen demonstrates influence over the regression model based on leverage.
The solid line represents the fitted regression model talking about relationship between x1 and y.
The dashed lines show the 95% confidence interval for mean, while dotted lines are 95%
prediction interval for observations. As expected, the prediction interval is wider than
confidence interval since it accounts for both model uncertainty and variability. Data point
seems to go with a strong linear trend.
The scatterplot of y versus x2 does not indicate strong linear relationship. These data points are
widely scattered, indicating that x2 is not a strong predictor of y.
a. Estimated model y = 0.435347 + 1.652993x1 + 0.003945x2
Coefficient Estimates
β 0 (Intercept) = 0.4353
β 1 (x1) = 1.6530
β 2 (x2) = 0.0039
Estimated Error Variance
2
0 = 0.01270523
95% Confidence Intervals are as follows:
Intercept: (0.2976, 0.5704)
X1: (1.4555, 1.8505)
X2: (-0.1513, 0.1592)
The Confidence Interval for X2 includes 0 which means that β 2 is not significantly different
from zero at a = 0.05.
b. Model Reduction
The 95% confidence interval for β2 was (−0.1513, 0.1592), which includes zero. Therefore, β2 is
not statistically significant at α = 0.05, and the model was reduced by removing x2.
c. Residual Analysis
Diagnostic Plots
d. Plot fitted line + 95% CI + prediction interval
The fitted regression line for the reduced model is shown above. The dashed curves represent
95% confidence interval for mean, while dotted curves represent the 95% prediction interval for
a new observation. The prediction interval is wider than the confidence interval, as expected,
due to additional variability associated with predicting individual responses.
MLR Simulation Exercise
The scatterplots of y versus x1 and y versus x2 show a positive relationship between response
and predictor. There is noticeable variability and with a small size, the upward trend is present in
both plots. Since x2 is a linear transformation of x1, both predictors offer the same information.
Thus, x1 or x2 could describe variation in y.
Part B.
Model: y ~ x1
Coefficients:
(Intercept) 12.1775
x1 -0.6258
Model 1 (y ~ x1)
2.5 % 97.5 %
(Intercept) -0.5426374 24.897637
x1 -3.1447959 1.893129
The estimated error variance was 𝜎2 = 44.51
Model 2 (y ~ x2)
Slope estimate: 0.2865
p-value: 0.274
CI includes 0
Insignificant. Neither slope is significantly different from zero, or show evidence of a linear
relationship with y.
Conclusion
In the end, multiple regression analysis show that x1 is the main predictor of y in the first dataset,
while x2 does not contribute very much to the model. In the simulation, neither predictor
showed much power, likely due to small sample size.