1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Inference in Python

Exercise

Testing for correlation

You want to understand if rent prices in Las Vegas and Houston are correlated or not. If you see prices rising in Las Vegas, is it reasonable to assume they are also rising in Houston? 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.

Instructions

100 XP
  • Create a line graph with two lines, one for houston_rents and one for lasvegas_rents, using the dates on the x-axis.
  • Compute the Pearson correlation coefficient and its associated p-value.
  • Determine and print out a Boolean that tells you whether the p-value is significant at the 5% level.
  • Print out R-squared.