Refactor extraction of raw terms from regression result
This commit is contained in:
parent
f9a8a5cf01
commit
fd30a3c1c7
@ -455,6 +455,18 @@ class RegressionModel:
|
||||
|
||||
return out
|
||||
|
||||
def terms_flat(self):
|
||||
"""
|
||||
Iterate over each :class:`SingleTerm` in *self.terms*, recursively stepping through :class:`CategoricalTerm`\ s
|
||||
"""
|
||||
|
||||
for t in self.terms.values():
|
||||
if isinstance(t, CategoricalTerm):
|
||||
for t in t.categories.values():
|
||||
yield t
|
||||
else:
|
||||
yield t
|
||||
|
||||
# --------------------
|
||||
# Post hoc tests, etc.
|
||||
|
||||
@ -477,12 +489,8 @@ class RegressionModel:
|
||||
|
||||
# Get parameters required for AFBF
|
||||
raw_params = {}
|
||||
for t in self.terms.values():
|
||||
if isinstance(t, CategoricalTerm):
|
||||
for t in t.categories.values():
|
||||
raw_params[t.raw_name.replace('[', '_').replace(']', '_')] = t.beta.point
|
||||
else:
|
||||
raw_params[t.raw_name.replace('[', '_').replace(']', '_')] = t.beta.point
|
||||
for t in self.terms_flat():
|
||||
raw_params[t.raw_name.replace('[', '_').replace(']', '_')] = t.beta.point
|
||||
|
||||
# Compute BF matrix
|
||||
bf01 = bayesfactor_afbf(pd.Series(raw_params), self.vcov, self.nobs, '{} = 0'.format(term.replace('[', '_').replace(']', '_')))
|
||||
|
Loading…
Reference in New Issue
Block a user