@@ -102,14 +102,20 @@ def print_coefficients(self, round_to=None) -> None:
102
102
... "progressbar": False
103
103
... }),
104
104
... )
105
- >>> result.print_coefficients(round_to=1) # doctest: +NUMBER
105
+ >>> result.print_coefficients(round_to=1)
106
106
Model coefficients:
107
- Intercept 1, 94% HDI [1, 1]
108
- post_treatment[T.True] 1, 94% HDI [0.9, 1]
109
- group 0.2, 94% HDI [0.09, 0.2]
110
- group:post_treatment[T.True] 0.5, 94% HDI [0.4, 0.6]
111
- sigma 0.08, 94% HDI [0.07, 0.1]
107
+ Intercept 1, 94% HDI [1, 1]
108
+ post_treatment[T.True] 1, 94% HDI [0.9, 1]
109
+ group 0.2, 94% HDI [0.09, 0.2]
110
+ group:post_treatment[T.True] 0.5, 94% HDI [0.4, 0.6]
111
+ sigma 0.08, 94% HDI [0.07, 0.1]
112
112
"""
113
+
114
+ def print_row (max_label_length , name , coeff_samples , round_to ):
115
+ formatted_name = f" { name : <{max_label_length }} "
116
+ formatted_val = f"{ round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
117
+ print (f" { formatted_name } { formatted_val } " )
118
+
113
119
print ("Model coefficients:" )
114
120
coeffs = az .extract (self .idata .posterior , var_names = "beta" )
115
121
@@ -118,16 +124,12 @@ def print_coefficients(self, round_to=None) -> None:
118
124
119
125
for name in self .labels :
120
126
coeff_samples = coeffs .sel (coeffs = name )
121
- print (
122
- f" { name : <{max_label_length }} \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
123
- )
127
+ print_row (max_label_length , name , coeff_samples , round_to )
124
128
125
129
# Add coefficient for measurement std
126
130
coeff_samples = az .extract (self .model .idata .posterior , var_names = "sigma" )
127
131
name = "sigma"
128
- print (
129
- f" { name : <{max_label_length }} \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
130
- )
132
+ print_row (max_label_length , name , coeff_samples , round_to )
131
133
132
134
133
135
class PrePostFit (ExperimentalDesign , PrePostFitDataValidator ):
@@ -163,13 +165,13 @@ class PrePostFit(ExperimentalDesign, PrePostFitDataValidator):
163
165
... }
164
166
... ),
165
167
... )
166
- >>> result.summary(round_to=1) # doctest: +NUMBER
168
+ >>> result.summary(round_to=1)
167
169
==================================Pre-Post Fit==================================
168
170
Formula: actual ~ 0 + a + g
169
171
Model coefficients:
170
- a 0.6, 94% HDI [0.6, 0.6]
171
- g 0.4, 94% HDI [0.4, 0.4]
172
- sigma 0.8, 94% HDI [0.6, 0.9]
172
+ a 0.6, 94% HDI [0.6, 0.6]
173
+ g 0.4, 94% HDI [0.4, 0.4]
174
+ sigma 0.8, 94% HDI [0.6, 0.9]
173
175
"""
174
176
175
177
def __init__ (
@@ -1184,10 +1186,10 @@ class PrePostNEGD(ExperimentalDesign, PrePostNEGDDataValidator):
1184
1186
Results:
1185
1187
Causal impact = 2, $CI_{94%}$[2, 2]
1186
1188
Model coefficients:
1187
- Intercept -0.5, 94% HDI [-1, 0.2]
1188
- C(group)[T.1] 2, 94% HDI [2, 2]
1189
- pre 1, 94% HDI [1, 1]
1190
- sigma 0.5, 94% HDI [0.5, 0.6]
1189
+ Intercept -0.5, 94% HDI [-1, 0.2]
1190
+ C(group)[T.1] 2, 94% HDI [2, 2]
1191
+ pre 1, 94% HDI [1, 1]
1192
+ sigma 0.5, 94% HDI [0.5, 0.6]
1191
1193
"""
1192
1194
1193
1195
def __init__ (
0 commit comments