-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
78 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/example | ||
*__pycache__ | ||
*.DS_Store | ||
*.ipynb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,10 @@ Development Lead | |
---------------- | ||
|
||
* Toomas Erik Anijärv <[email protected]> | ||
* Rory Boyle <[email protected]> | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jules Mitchell | ||
* Rory Boyle | ||
* Cate Scanlon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
__author__ = """Toomas Erik Anijärv""" | ||
__email__ = '[email protected]' | ||
__version__ = '0.2.0' | ||
__version__ = '0.2.3' | ||
|
||
from .diagnostic_tests import (test_durbin_watson, | ||
test_pearsons_r, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
"""Functions for diagnostic tests to test for assumptions. | ||
Authors | ||
------- | ||
Toomas Erik Anijärv [email protected] github.com/teanijarv | ||
Rory Boyle [email protected] github.com/rorytboyle | ||
""" | ||
|
||
"""Functions for diagnostic tests to test for assumptions.""" | ||
import scipy.stats | ||
import numpy as np | ||
from statsmodels.stats.stattools import durbin_watson | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
"""Functions for running hierarchical linear regression. | ||
Authors | ||
------- | ||
Toomas Erik Anijärv [email protected] github.com/teanijarv | ||
Rory Boyle [email protected] github.com/rorytboyle | ||
""" | ||
"""HLR - Hierarchical Linear Regression.""" | ||
import pandas as pd | ||
import statsmodels.api as sm | ||
import scipy.stats | ||
|
@@ -215,7 +209,11 @@ def diagnostics(self, verbose=True): | |
return diagnostics_results | ||
|
||
def plot_studentized_residuals_vs_fitted(self): | ||
"""Plots studentized residuals against fitted values for all model levels.""" | ||
"""Plots studentized residuals against fitted values for all model levels. | ||
Returns: | ||
matplotlib.figure.Figure: The matplotlib figure object. | ||
""" | ||
model_results = self.fit_models() | ||
num_levels = len(model_results) | ||
|
||
|
@@ -229,9 +227,15 @@ def plot_studentized_residuals_vs_fitted(self): | |
|
||
plt.tight_layout() | ||
plt.show() | ||
|
||
return fig | ||
|
||
def plot_qq_residuals(self): | ||
"""Plots Normal QQ Plots for all model levels.""" | ||
"""Plots Normal QQ Plots for all model levels. | ||
Returns: | ||
matplotlib.figure.Figure: The matplotlib figure object. | ||
""" | ||
model_results = self.fit_models() | ||
fig, axs = plt.subplots(len(model_results), 1, figsize=(8, 4 * len(model_results))) | ||
if len(model_results) == 1: | ||
|
@@ -243,8 +247,14 @@ def plot_qq_residuals(self): | |
plt.tight_layout() | ||
plt.show() | ||
|
||
return fig | ||
|
||
def plot_influence(self): | ||
"""Plots Influence Plots for all model levels.""" | ||
"""Plots Influence Plots for all model levels. | ||
Returns: | ||
matplotlib.figure.Figure: The matplotlib figure object. | ||
""" | ||
model_results = self.fit_models() | ||
fig, axs = plt.subplots(len(model_results), 1, figsize=(8, 4 * len(model_results))) | ||
if len(model_results) == 1: | ||
|
@@ -256,8 +266,14 @@ def plot_influence(self): | |
plt.tight_layout() | ||
plt.show() | ||
|
||
return fig | ||
|
||
def plot_std_residuals(self): | ||
"""Plots Box Plots of Standardized Residuals for all model levels.""" | ||
"""Plots Box Plots of Standardized Residuals for all model levels. | ||
Returns: | ||
matplotlib.figure.Figure: The matplotlib figure object. | ||
""" | ||
model_results = self.fit_models() | ||
fig, axs = plt.subplots(len(model_results), 1, figsize=(8, 4 * len(model_results))) | ||
if len(model_results) == 1: | ||
|
@@ -270,9 +286,15 @@ def plot_std_residuals(self): | |
|
||
plt.tight_layout() | ||
plt.show() | ||
|
||
return fig | ||
|
||
def plot_histogram_std_residuals(self): | ||
"""Plots Histogram of Standardized Residuals for all model levels.""" | ||
"""Plots Histogram of Standardized Residuals for all model levels. | ||
Returns: | ||
matplotlib.figure.Figure: The matplotlib figure object. | ||
""" | ||
model_results = self.fit_models() | ||
fig, axs = plt.subplots(len(model_results), 1, figsize=(8, 4 * len(model_results))) | ||
if len(model_results) == 1: | ||
|
@@ -286,11 +308,21 @@ def plot_histogram_std_residuals(self): | |
plt.tight_layout() | ||
plt.show() | ||
|
||
return fig | ||
|
||
def plot_partial_regression(self): | ||
"""Plots Partial Regression Plots for all model levels.""" | ||
"""Plots Partial Regression Plots for all model levels. | ||
Returns: | ||
list: A list of matplotlib.figure.Figure objects, one for each model level. | ||
""" | ||
model_results = self.fit_models() | ||
num_ivs = max(len(ivs) for ivs in self.models.values()) | ||
fig_size = (15, min(10, 5 * num_ivs)) | ||
|
||
fig_list = [] | ||
for level, model in model_results.items(): | ||
plots.create_subplot_partial_regression(model, fig_size, level) | ||
fig = plots.create_subplot_partial_regression(model, fig_size, level) | ||
fig_list.append(fig) | ||
|
||
return fig_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters