Skip to main content

a Python package for analyzing the correlation between macroeconomic indicators and time-series data

Project description

macroecon

Macrocorr (’macroeconomic correlation’) is a Python package for analyzing the correlation between macroeconomic indicators and time-series data.

Pearson's correlation is used to analyze the correlation. This package uses SciPy’s built function to get the Pearson coefficient. For details, please check out scipy.stats.pearsonr.

This package is designed to provide the easy process of analyzing and comparing the correlations with multiple macroeconomic indicators at a single time. The result is intended to provide an overview of macroeconomic relationships. It should not be used for profitable purposes.

The data of the macroeconomic indicators are extracted from WorldBank and YahooFinance historical database. This package doesn’t guarantee the accuracy of the correlated data.

Installation

The latest stable release (and required dependencies) can be installed from pip.

pip install macrocorr

Usage

  • For all macroeconomic indicators and all major categories, check out CATALOG.
  • For more detailed uses of the functions, check out FUNCTIONS.
  • For a step-by-step example use-case, check out example_basic.ipynb.

Quick Start

  1. Import package Macrocorr
import macrocorr as mcrr
  1. Create a correlator with the data you want to analyze
my_correlator= mcrr.Correlator(date=my_data['Date'].values, data_x=my_data['Price'].values)
# data_x should be an one-dimensional array of numerical value
# make sure the values from date and data_x are matched
  1. Analyze and compare the correlation with the macroeconomic indicators from a category
my_correlator.analyze_Correlation(category='population', country='USA', top_num=3)
# print the top 3 most correlated indicators from the category (='population') 
# with their respective Pearson's coefficient and p-value
# plot the graph with both the input data and data of the most correlated indicator
  1. Analyze the correlation with one specific indicator
my_correlator.get_Correlation(y_name="Population, total", graph=True)
# print the Pearson's coefficient and p-value of the indicator (='Population, total') 
# plot the graph with both the input data and data of the indicator

Contributing

Development takes place on Github

Pull requests are welcome. Feel free to add more macroeconomic indicators or analysis methods.

For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

macrocorr-0.1.6-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page