Predicting house prices
Perhaps the most useful feature of statistical models like linear regression is that you can make predictions. That is, you specify values for each of the explanatory variables, feed them to the model, and you get a prediction for the corresponding response variable. The code flow is as follows.
explanatory_data <- tibble(
explanatory_var = some_values
)
explanatory_data %>%
mutate(
response_var = predict(model, explanatory_data)
)
Here, you'll make predictions for the house prices in the Taiwan real estate dataset.
taiwan_real_estate
is available. The linear regression model of house price versus number of convenience stores is available as mdl_price_vs_conv
(print it and read the call to see how it was made); and dplyr
is loaded.
This exercise is part of the course
Introduction to Regression in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create a tibble with n_convenience column from zero to ten
explanatory_data <- ___