From 7ac849edbb38aeefadcca1a0ba773bb8b1bd3532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toomas=20Erik=20Anij=C3=A4rv?= Date: Fri, 24 Feb 2023 11:50:31 +1000 Subject: [PATCH] Usage edits --- README.md | 14 +++++++++----- docs/usage.rst | 21 +++++++++++++++++++++ example/usage.ipynb | 6 +++--- setup.py | 2 +- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9008438..78f89bb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ HLR is a simple Python package for running hierarchical regression. It was creat It is built to work with Pandas dataframes, uses SciPy and statsmodels for all statistics and regression functions, and runs diagnostic tests for testing assumptions while plotting figures with matplotlib and seaborn. ## Installation -HLR is meant to be used with Python 3.x and has been tested on Python 3.6-3.9. +HLR is meant to be used with Python 3.x and has been tested on Python 3.7-3.9. #### Dependencies - [NumPy](https://numpy.org/) @@ -33,7 +33,7 @@ An example Jupyter Notebook can be found in 'example' subfolder with a sample da ```python import pandas as pd -import hlr +import HLR nba = pd.read_csv('example/NBA_train.csv') @@ -51,9 +51,9 @@ X_names = [['points'], y = nba[['W']] # Create a HLR model with diagnostic tests, run and save the results -hlr_model = hlr.HLR(diagnostics=True, showfig=True, save_folder='results', verbose=True) -model_results, reg_models = hlr_model.run(X=X, X_names=X_names, y=y) -hlr_model.save_results(filename='nba_results', show_results=True) +model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True) +model_results, reg_models = model.run(X=X, X_names=X_names, y=y) +model.save_results(filename='nba_results', show_results=True) ``` OUTPUT (without figures): | | Step | Predictors | N (observations) | DF (residuals) | DF (model) | R-squared | F-value | P-value (F) | SSE | SSTO | MSE (model) | MSE (residuals) | MSE (total) | Beta coefs | P-values (beta coefs) | Failed assumptions (check!) | R-squared change | F-value change | P-value (F change) | @@ -71,6 +71,10 @@ HLR was created by [Toomas Erik Anijärv](https://www.toomaserikanijarv.com) usi This program is provided with no warranty of any kind and it is still under heavy development. However, this code has been checked and validated against multiple same analyses conducted in SPSS. +#### To-do +- Documentation +- More thorough testing + #### Contributors [Toomas Erik Anijärv](https://github.com/teanijarv) [Rory Boyle](https://github.com/rorytboyle) diff --git a/docs/usage.rst b/docs/usage.rst index c3f8aa8..d4803b9 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -4,4 +4,25 @@ Usage To use HLR - Hierarchical Linear Regression in a project:: + import pandas as pd + import os import HLR + + nba = pd.read_csv('example/NBA_train.csv') + + # List of dataframes of predictor variables for each step + X = [nba[['PTS']], + nba[['PTS', 'ORB']], + nba[['PTS', 'ORB', 'BLK']]] + + # List of predictor variable names for each step + X_names = [['points'], + ['points', 'offensive_rebounds'], + ['points', 'offensive_rebounds', 'blocks']] + + # Outcome variable as dataframe + y = nba[['W']] + + model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True) + model_results, reg_models = model.run(X=X, X_names=X_names, y=y) + model.save_results(filename='nba_results', show_results=True) \ No newline at end of file diff --git a/example/usage.ipynb b/example/usage.ipynb index a7ebde2..690b006 100644 --- a/example/usage.ipynb +++ b/example/usage.ipynb @@ -325,9 +325,9 @@ "# Outcome variable as dataframe\n", "y = nba[['W']]\n", "\n", - "hlr_model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)\n", - "model_results, reg_models = hlr_model.run(X=X, X_names=X_names, y=y)\n", - "hlr_model.save_results(filename='test', show_results=True)" + "model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)\n", + "model_results, reg_models = model.run(X=X, X_names=X_names, y=y)\n", + "model.save_results(filename='nba_results', show_results=True)" ] } ], diff --git a/setup.py b/setup.py index 9d1860e..c35a9e7 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/teanijarv/HLR', - version='0.1.0', + version='0.1.1', zip_safe=False, )