Skip to content

Commit

Permalink
Usage edits
Browse files Browse the repository at this point in the history
  • Loading branch information
teanijarv committed Feb 24, 2023
1 parent 20f7fb3 commit 7ac849e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand All @@ -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')

Expand All @@ -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) |
Expand All @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions example/usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 7ac849e

Please sign in to comment.