-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lme2 #38
Lme2 #38
Changes from all commits
6a247a7
f13954d
5a7ad7a
241f2a2
5a53409
145ca2e
66e146d
ea3669c
e10bd6f
ec77bfa
af5f730
eecf811
a78b49f
9922347
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#!/usr/bin/env python | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2016--, gneiss development team. | ||
# | ||
|
@@ -39,26 +37,29 @@ def __init__(self, | |
self.basis = basis | ||
self.results = stat_results | ||
|
||
# sum of squares error. Also referred to as sum of squares residuals | ||
sse = 0 | ||
# sum of squares regression. Also referred to as | ||
# explained sum of squares. | ||
ssr = 0 | ||
# See `statsmodels.regression.linear_model.RegressionResults` | ||
# for more explanation on `ess` and `ssr`. | ||
|
||
# obtain pvalues | ||
self.pvalues = pd.DataFrame() | ||
for r in self.results: | ||
p = r.pvalues | ||
p.name = r.model.endog_names | ||
self.pvalues = self.pvalues.append(p) | ||
sse += r.ssr | ||
ssr += r.ess | ||
|
||
@property | ||
def r2(self): | ||
""" Calculates the coefficients of determination """ | ||
# Reason why we wanted to move this out was because not | ||
# all types of statsmodels regressions have this property. | ||
|
||
# See `statsmodels.regression.linear_model.RegressionResults` | ||
# for more explanation on `ess` and `ssr`. | ||
# sum of squares regression. Also referred to as | ||
# explained sum of squares. | ||
ssr = sum([r.ess for r in self.results]) | ||
# sum of squares error. Also referred to as sum of squares residuals | ||
sse = sum([r.ssr for r in self.results]) | ||
# calculate the overall coefficient of determination (i.e. R2) | ||
sst = sse + ssr | ||
self.r2 = 1 - sse / sst | ||
return 1 - sse / sst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any tests that need to be modified/created? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. This is handled within the ols results. Note that I wanted to move this outside of the constructor, because linear mixed effects models don't have an r2. |
||
|
||
def _check_projection(self, project): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any easy way to exercise the kwargs in the unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly. Give me a sec.