IniziaInizia gratis

Computing the R-squared of a model

Let's compute the \(R^2\) summary value for the two numerical explanatory/predictor variable model you fit in the Chapter 3, price as a function of size and the number of bedrooms.

Recall that \(R^2\) can be calculated as:

$$1 - \frac{\text{Var}(\text{residuals})}{\text{Var}(y)}$$

Questo esercizio fa parte del corso

Modeling with Data in the Tidyverse

Visualizza il corso

Istruzioni dell'esercizio

Compute \(R^2\) by summarizing the residual and log10_price columns.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Fit model
model_price_2 <- lm(log10_price ~ log10_size + bedrooms,
                    data = house_prices)
                    
# Get fitted/values & residuals, compute R^2 using residuals
get_regression_points(model_price_2) %>%
  ___(r_squared = ___ - ___(___) / ___(___))
Modifica ed esegui il codice