Skip to content

Commit 7ac849e

Browse files
committed
Usage edits
1 parent 20f7fb3 commit 7ac849e

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ HLR is a simple Python package for running hierarchical regression. It was creat
77
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.
88

99
## Installation
10-
HLR is meant to be used with Python 3.x and has been tested on Python 3.6-3.9.
10+
HLR is meant to be used with Python 3.x and has been tested on Python 3.7-3.9.
1111

1212
#### Dependencies
1313
- [NumPy](https://numpy.org/)
@@ -33,7 +33,7 @@ An example Jupyter Notebook can be found in 'example' subfolder with a sample da
3333

3434
```python
3535
import pandas as pd
36-
import hlr
36+
import HLR
3737

3838
nba = pd.read_csv('example/NBA_train.csv')
3939

@@ -51,9 +51,9 @@ X_names = [['points'],
5151
y = nba[['W']]
5252

5353
# Create a HLR model with diagnostic tests, run and save the results
54-
hlr_model = hlr.HLR(diagnostics=True, showfig=True, save_folder='results', verbose=True)
55-
model_results, reg_models = hlr_model.run(X=X, X_names=X_names, y=y)
56-
hlr_model.save_results(filename='nba_results', show_results=True)
54+
model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)
55+
model_results, reg_models = model.run(X=X, X_names=X_names, y=y)
56+
model.save_results(filename='nba_results', show_results=True)
5757
```
5858
OUTPUT (without figures):
5959
| | 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
7171

7272
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.
7373

74+
#### To-do
75+
- Documentation
76+
- More thorough testing
77+
7478
#### Contributors
7579
[Toomas Erik Anijärv](https://github.com/teanijarv)
7680
[Rory Boyle](https://github.com/rorytboyle)

docs/usage.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,25 @@ Usage
44

55
To use HLR - Hierarchical Linear Regression in a project::
66

7+
import pandas as pd
8+
import os
79
import HLR
10+
11+
nba = pd.read_csv('example/NBA_train.csv')
12+
13+
# List of dataframes of predictor variables for each step
14+
X = [nba[['PTS']],
15+
nba[['PTS', 'ORB']],
16+
nba[['PTS', 'ORB', 'BLK']]]
17+
18+
# List of predictor variable names for each step
19+
X_names = [['points'],
20+
['points', 'offensive_rebounds'],
21+
['points', 'offensive_rebounds', 'blocks']]
22+
23+
# Outcome variable as dataframe
24+
y = nba[['W']]
25+
26+
model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)
27+
model_results, reg_models = model.run(X=X, X_names=X_names, y=y)
28+
model.save_results(filename='nba_results', show_results=True)

example/usage.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@
325325
"# Outcome variable as dataframe\n",
326326
"y = nba[['W']]\n",
327327
"\n",
328-
"hlr_model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)\n",
329-
"model_results, reg_models = hlr_model.run(X=X, X_names=X_names, y=y)\n",
330-
"hlr_model.save_results(filename='test', show_results=True)"
328+
"model = HLR.HLR_model(diagnostics=True, showfig=True, save_folder='results', verbose=True)\n",
329+
"model_results, reg_models = model.run(X=X, X_names=X_names, y=y)\n",
330+
"model.save_results(filename='nba_results', show_results=True)"
331331
]
332332
}
333333
],

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@
5050
test_suite='tests',
5151
tests_require=test_requirements,
5252
url='https://github.com/teanijarv/HLR',
53-
version='0.1.0',
53+
version='0.1.1',
5454
zip_safe=False,
5555
)

0 commit comments

Comments
 (0)