From dce49613145889a96b08a3211dfff75c3f8dc104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Thu, 6 Apr 2023 10:28:25 +1000 Subject: [PATCH] version bump prep - changes made by Jules reviewed - added pingouin dependency --- HISTORY.rst | 10 +++++++++- HLR/hierarchical_regression.py | 7 ++++++- README.md | 4 +++- requirements.txt | 3 ++- setup.py | 5 +++-- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 36b3730..ba14a64 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,4 +13,12 @@ History * Fixed pairwise correlations threshold for multicollinearity assumption testing (0.3 -> 0.7) * Fixed partial regression plots fixed figure size * Added titles to diagnostic plots -* Fixed the VIF to match with SPSS output by adding the constant to X \ No newline at end of file +* Fixed the VIF to match with SPSS output by adding the constant to X + +0.1.5 (2023-04-6) +------------------ + +* Added standardised beta coefficients to model output +* Added partial and semi-partial correlations (unique variance) to model output +* Fixed F-change degrees of freedom calculation +* Fixed F-change p-value calculation \ No newline at end of file diff --git a/HLR/hierarchical_regression.py b/HLR/hierarchical_regression.py index d8770bc..8a73ad0 100644 --- a/HLR/hierarchical_regression.py +++ b/HLR/hierarchical_regression.py @@ -72,7 +72,8 @@ def linear_reg(X, X_names, y): beta_conversion = [b * c for b,c in zip(coeffs_values, conversion)] std_coeffs = dict(zip(coeffs_keys, beta_conversion)) # 25/03/23 dictionary to store beta_coefficients - # 05/04/2023 - Calculate the partial and semi-partial (part in SPSS) correlations for each X value with y, while holding other X values as covariates + # 05/04/2023 - Calculate the partial and semi-partial (defined 'part' in SPSS) correlations + # for each X value with y, while holding other X values as covariates # Initialize an array to store partial and semi-partial correlation values x_cols = [X.columns.tolist()] semi_partial_correlations = np.zeros(len(x_cols[0])) @@ -225,6 +226,10 @@ def hierarchical_regression(X, X_names, y, diagnostics=True, save_folder='result MSE (total) = total mean square error Beta coefs = coefficient values for intercept and predictors P-values (beta coefs) = p-values for intercept and predictors + Std Beta coefs = standardised beta coefficients for intercept and predictors + Partial correlation = partial correlation for each X value with y + Semi-partial correlation = semi-partial correlation for each X value with y + Unique Variance % = squared semi-partial correlation for unique variance of predictors R-squared change = r-squared change for model (Step 2 r-sq - Step 1 r-sq) F-value change = f change for model (Step 2 f - Step 1 f) P-value (F change) = p-value of f-change of model diff --git a/README.md b/README.md index a429ec1..65d7a63 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HLR - Hierarchical Linear Regression in Python -[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7683809.svg)](https://doi.org/10.5281/zenodo.7683809) [![image](https://img.shields.io/pypi/v/HLR.svg)](https://pypi.python.org/pypi/HLR) [![image](https://img.shields.io/travis/teanijarv/HLR.svg)](https://travis-ci.com/teanijarv/HLR) [![Documentation Status](https://readthedocs.org/projects/hlr-hierarchical-linear-regression/badge/?version=latest)](https://hlr-hierarchical-linear-regression.readthedocs.io/en/latest/?version=latest) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7683809.svg)](https://doi.org/10.5281/zenodo.7683809) [![image](https://img.shields.io/pypi/v/HLR.svg)](https://pypi.python.org/pypi/HLR) [![Build Status](https://app.travis-ci.com/teanijarv/HLR.svg?branch=main)](https://app.travis-ci.com/teanijarv/HLR) [![Documentation Status](https://readthedocs.org/projects/hlr-hierarchical-linear-regression/badge/?version=latest)](https://hlr-hierarchical-linear-regression.readthedocs.io/en/latest/?version=latest) HLR is a simple Python package for running hierarchical regression. It was created because there wasn't any good options to run hierarchical regression without using programs like SPSS. @@ -41,6 +41,7 @@ HLR is meant to be used with Python 3.x and has been tested on Python 3.7-3.9. - [SciPy](https://www.scipy.org/) - [Pandas](https://pandas.pydata.org/) - [statsmodels](https://www.statsmodels.org/) +- [pingouin](https://pingouin-stats.org/) - [matplotlib](https://matplotlib.org/) - [seaborn](https://seaborn.pydata.org/) @@ -158,6 +159,7 @@ Would be great if someone with more experience with packages would contribute wi #### Contributors [Toomas Erik Anijärv](https://github.com/teanijarv) [Rory Boyle](https://github.com/rorytboyle) +[Jules Mitchell](https://github.com/JulesMitchell) #### Credits This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template. diff --git a/requirements.txt b/requirements.txt index fd48360..01267b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ scipy==1.7.3 pandas==1.3.5 matplotlib==3.5.2 seaborn==0.11.2 -statsmodels==0.13.2 \ No newline at end of file +statsmodels==0.13.2 +pingouin==0.5.3 \ No newline at end of file diff --git a/setup.py b/setup.py index bd40eba..524bc61 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,8 @@ 'pandas>=1.3.5', 'matplotlib>=3.5.2', 'seaborn>=0.11', - 'statsmodels>=0.13'] + 'statsmodels>=0.13', + 'pingouin>=0.5.3'] test_requirements = ['pytest>=3'] @@ -50,6 +51,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/teanijarv/HLR', - version='0.1.4', + version='0.1.5', zip_safe=False, )