Week 8 Analysis
Chevrolet Malibus come in two main styles, either a hatchback or a sedan. When deciding to buy a Malibu one may consider, how much is a brand-new hatchback or sedan on average and are they different? Or maybe one thinking about the future will wonder even more interesting, how quickly will each of them depreciate in value? In this study, we will compare the zero-mileage costs and the depreciation rates between the Chevrolet Malibu sedan and the Chevrolet Malibu hatchback.
The linear model we will be using is given below, with the hatchback being the baseline and the sedan being the adjustments to the baseline.
\[ \underbrace{Y_i}_{\text{Price}} = \overbrace{\beta_0 + \beta_1 \underbrace{X_{i1}}_{\text{Mileage}}}^{\text{Hatchback Line}} + \overbrace{\beta_2 \underbrace{X_{i2}}_{\text{1 if Sedan}} + \beta_3 \underbrace{X_{i1} X_{i2}}_{\text{Interaction}}}^{\text{Sedan Adjustments to Line}} + \epsilon_i \]
Our first hypotheses concern \(\beta_2\), the change in the y-intercept. If \(\beta_2 = 0\) then the sedan and hatchback cost the same on average when they have zero miles. If \(\beta_2 \neq 0\) then there is a difference.
\[ \begin{align} &H_0: \beta_2 = 0 \quad \text{(Equal average cost when brand new)} \\ &H_a: \beta_2 \neq 0 \quad \text{(Non-equal average cost when brand new)} \end{align} \]
Our second hypotheses concern \(\beta_3\), the change in the slope. If \(\beta_3 = 0\) then the sedan and hatchback have the same rates of on depreciation on average. If \(\beta_3 \neq 0\) then there is a difference.
\[ \begin{align} &H_0: \beta_3 = 0 \quad \text{(Equal rates of depreciation)} \\ &H_a: \beta_3 \neq 0 \quad \text{(Non-equal rates of depreciation)} \end{align} \]
For both of these hypotheses, our level of significance will be \(\alpha = 0.05.\)
malibu.lm <- lm(Price ~ Mileage + Type + Mileage:Type, data = MalibuPrices)
palette(c("springgreen3", "dodgerblue3"))
par(mfrow = c(1,1))
plot(Price ~ Mileage,
col = as.factor(Type),
data = MalibuPrices,
pch = 16,
ylim = c(15000, 20100),
main = "Zero-Mileage Price and Rate of Depreciation\nfor the Chevrolet Malibu")
b <- coef(malibu.lm)
abline(b[1], b[2], col = palette()[1])
abline(b[1] + b[3], b[2] + b[4] , col = palette()[2])
legend("topright",
legend = c("Hatchback", "Sedan"),
pch = 16,
col = palette(),
title = "Type",
bty = "n")
From the plot above it appears that the hatchback and the sedan have different zero-mileage prices and slightly different rates of depreciation. The results below from the regression model confirm that a hatchback and a sedan have different prices when they are brand-new since \(p = 0.002962 < \alpha\). The difference in price is about $1032. However, the results say that there is no significant difference in the rates of depreciation since \(p = 0.08524 > \alpha\).
pander(summary(malibu.lm))
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
(Intercept) | 20173 | 238.9 | 84.42 | 9.997e-61 |
Mileage | -0.1455 | 0.01226 | -11.86 | 6.572e-17 |
TypeSedan | -1032 | 332.2 | -3.107 | 0.002962 |
Mileage:TypeSedan | 0.02865 | 0.01635 | 1.752 | 0.08524 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
60 | 457.7 | 0.8393 | 0.8307 |
The model’s appropriateness is shown by the plots below. The residuals vs fitted values plot show that there is constant variance and the regression relation is roughly linear. The normal Q-Q plot shows that the residuals are sufficiently normal. The residuals vs order plot is questionable as there seems to be a somewhat parabolic pattern.
par(mfrow = c(1,3))
plot(malibu.lm, which = 1)
qqPlot(malibu.lm$residuals,
ylab = "Standardised Residuals",
xlab = "Theoretical Quantiles")
title("Normal Q-Q", line = .5,
cex.main = 1.5, font.main = 1)
plot(malibu.lm$residuals,
ylab = "Residuals")
title("Residuals vs Order", line = .5,
cex.main = 1.5, font.main = 1)
Our results show that there is a difference in the price of the Chevrolet Malibu hatchback and a Chevrolet Malibu sedan when they are brand-new, with the sedan being about $1032 less than the hatchback. However, there is not a difference in the rates of depreciation so, in other words, both vehicles lose the same amount of value on average per mile driven. In another study, we might find more interesting results in comparing the rate of depreciation of the Chevy Malibu with another Chevy model, for example, the Corvette.