Explained variance
You saw that rent prices between Houston and Las Vegas are correlated. However, to what extent can the price change in one city explain the price change in another city? By computing R-squared you are able to precisely quantify this.
A NumPy array of rents has been loaded for Las Vegas (lasvegas_rents) and Houston (houston_rents), as well as the dates associated with each measurement. The packages pandas as pd, NumPy as np, Matplotlib as plt, and the stats package from SciPy have all been loaded for you.
Diese Übung ist Teil des Kurses
Foundations of Inference in Python
Anleitung zur Übung
- Compute the Pearson correlation coefficient between 
houston_rentsandlasvegas_rents. - Print the square of the correlation coefficient.
 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Compute the correlation between Houston and Las Vegas
r, p_value = ____
# Print R-squared
____