0
$\begingroup$

I'm doing a research project and want to test for correlation between different data sets.

For example, I want to test if there is a correlation between median house prices and homeless population in the US by year. Here is some made up data for the problem:

Year 2000 , House price $260,000, homeless pop 330,000

2005 - 270,000 - 315,000

2010 - 285,000 - 320,000

2015 - 330,000 - 340,000

2020 - 400,000 - 370,000

I want to then get (r) to measure the correlation between these two data sets and compare that strength of correlation to other data sets (for example, median house price and rates of domestic violence in the US)

Thank you for the help!

$\endgroup$
1
  • $\begingroup$ The data didn't format well on this post. The point is that for each year I have a median house price data point and a homeless population data point, and I want to see how those data sets are correlated to each other if at all $\endgroup$
    – James
    Commented May 31, 2023 at 17:47

1 Answer 1

0
$\begingroup$

It would depend on your specific problem statement, if you do not want to consider this as a time series data i.e. do not want to take year into account you would simply consider the correlation values between the home price and homeless population versus home price and domestic violence; whichever value will be high in magnitude (positively or negatively correlated) will be strongly correlated than the other

data_df['Home Price'].corr(data_df['Homeless pop'])

data_df['Home Price'].corr(data_df['Domestic Violence rate'])

If you want to consider time factor ; then you would have to convert the date column into datetime column and then consider three different time series

  1. Year and home price
  2. Year and homeless pop
  3. Year and domestic violence rate

And then you can use granger causality test for causality or cross correlation to see the correlation between time series. You can refer to this post as well -

https://towardsdatascience.com/computing-cross-correlation-between-geophysical-time-series-488642be7bf0#:~:text=Cross%2Dcorrelation%20is%20an%20established,inference%20on%20the%20seismic%20data.

$\endgroup$
2
  • $\begingroup$ Thank you so much for the response! I think you are right that I don't need to consider time factor. I'm using cor.test in Rstudio with my data set to find (r). Would you recommend any other analysis beyond that? $\endgroup$
    – James
    Commented May 31, 2023 at 19:17
  • $\begingroup$ I think you should be good with correlation. You can plot charts and do some data analysis around it. If you would like to predict the home prices based on the other columns - homeless pop , domestic violence. ** Please consider upvoting/accepting an answer if you find anything helpful.** $\endgroup$
    – Kriti
    Commented May 31, 2023 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.