Skip to content

Commit 9b1c6d1

Browse files
committed
BUG: TukeyBiweight shift rho, unit tests
1 parent 20b2f6c commit 9b1c6d1

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

statsmodels/robust/norms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ def rho(self, z):
806806
rho(z) = 0 for \|z\| > R
807807
"""
808808
subset = self._subset(z)
809-
return -(1 - (z / self.c)**2)**3 * subset * self.c**2 / 6.
809+
factor = self.c**2 / 6.
810+
return -(1 - (z / self.c)**2)**3 * subset * factor + factor
810811

811812
def psi(self, z):
812813
r"""

statsmodels/robust/tests/results/results_norms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@
1212
weights=[0.0, 0.1111111111111111, 0.75, 1.0, 1.0, 1.0, 0.75,
1313
0.1111111111111111, 0.0],
1414
)
15+
16+
res_biweight = Holder(
17+
rho=[2.6666666666666665, 2.6666666666666665, 1.5416666666666665,
18+
0.46940104166666663, 0.0, 0.46940104166666663, 1.5416666666666665,
19+
2.6666666666666665, 2.6666666666666665],
20+
psi=[0.0, 0.0, -1.125, -0.87890625, 0.0, 0.87890625, 1.125, 0.0, 0.0],
21+
psi_deriv=[0.0, 0.0, -0.1875, 0.64453125, 1.0, 0.64453125, -0.1875, 0.0,
22+
0.0],
23+
weights=[0.0, 0.0, 0.5625, 0.87890625, 1.0, 0.87890625, 0.5625, 0.0, 0.0],
24+
)

statsmodels/robust/tests/test_norms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from .results import results_norms as res_r
1212

1313
cases = [
14-
(norms.Hampel, (1.5, 3.5, 8.), res_r.res_hampel)
14+
(norms.Hampel, (1.5, 3.5, 8.), res_r.res_hampel),
15+
(norms.TukeyBiweight, (4,), res_r.res_biweight),
1516
]
1617

1718
dtypes = ["int", np.float64, np.complex128]

0 commit comments

Comments
 (0)