Question: Price and bedrooms. For each question, provide the R code used to generate your answer. (i) Run a regression of price on bedrooms. Store the
Price and bedrooms. For each question, provide the R code used to generate your answer.
(i) Run a regression of price on bedrooms. Store the results in an object named ols price bedrooms. How do you interpret the coefficient on bedrooms?
(ii) Now run a regression of price on bedrooms including only those observations for which the bedrooms variable is less than or equal to six. Store the results in an object named ols price bedrooms 6. Is the coefficient bigger or smaller than before? Why do you think that is?
(iii) Why might it make sense to take the log() of bedrooms in this case?
(iv) Create a variable, log bedrooms, inside of your data frame, equal to the log() of bedrooms by running the following line of code
houses$log bedrooms=log(houses$bedrooms)
Now run a regression of price on log bedrooms. Why didnt it work?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
