Multiple Linear Regression: Response Explanatory - I
Multiple Linear Regression: Response Explanatory - I
Before fitting our regression model we want to investigate how the variables are
related to one another. We can do this graphically by constructing scatter plots of
all pair-wise combinations of variables in the data frame. This can be done by
typing:
> plot(Housing2)
To fit a multiple linear regression model with price as the response variable and
size and lot as the explanatory variables, use the command:
> results = lm(Price ~ Size + Lot, data=Housing)
> results
Call:
lm(formula = Price ~ Size + Lot, data = Housing)
Coefficients:
(Intercept)
Size
Lot
-10535.951
53.779
2.840
This output indicates that the fitted value is given by y
H0 :
In R we can perform partial F-tests by fitting both the reduced and full models
separately and thereafter comparing them using the anova function.
Ex. Suppose we include the variables bedroom, bath, size and lot in our model
and are interested in testing whether the number of bedrooms and bathrooms
are significant after taking size and lot into consideration.
The following code performs the partial F-test:
> reduced = lm(Price ~ Size + Lot, data=Housing)
# Reduced model
> full = lm(Price ~ Size + Lot + Bedrooms + Baths, data=Housing) # Full Model
> anova(reduced, full)
Ex. Obtain a 95% confidence interval for the mean sales price of houses whose
size is 1,000 square feet and lot size is 20,000 square feet.
> results = lm(Price ~ Size + Lot, data=Housing)