Skip to content

Commit

Permalink
BUG: TukeyBiweight shift rho, unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-pkt committed Apr 15, 2023
1 parent 20b2f6c commit 9b1c6d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion statsmodels/robust/norms.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,8 @@ def rho(self, z):
rho(z) = 0 for \|z\| > R
"""
subset = self._subset(z)
return -(1 - (z / self.c)**2)**3 * subset * self.c**2 / 6.
factor = self.c**2 / 6.
return -(1 - (z / self.c)**2)**3 * subset * factor + factor

def psi(self, z):
r"""
Expand Down
10 changes: 10 additions & 0 deletions statsmodels/robust/tests/results/results_norms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@
weights=[0.0, 0.1111111111111111, 0.75, 1.0, 1.0, 1.0, 0.75,
0.1111111111111111, 0.0],
)

res_biweight = Holder(
rho=[2.6666666666666665, 2.6666666666666665, 1.5416666666666665,
0.46940104166666663, 0.0, 0.46940104166666663, 1.5416666666666665,
2.6666666666666665, 2.6666666666666665],
psi=[0.0, 0.0, -1.125, -0.87890625, 0.0, 0.87890625, 1.125, 0.0, 0.0],
psi_deriv=[0.0, 0.0, -0.1875, 0.64453125, 1.0, 0.64453125, -0.1875, 0.0,
0.0],
weights=[0.0, 0.0, 0.5625, 0.87890625, 1.0, 0.87890625, 0.5625, 0.0, 0.0],
)
3 changes: 2 additions & 1 deletion statsmodels/robust/tests/test_norms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from .results import results_norms as res_r

cases = [
(norms.Hampel, (1.5, 3.5, 8.), res_r.res_hampel)
(norms.Hampel, (1.5, 3.5, 8.), res_r.res_hampel),
(norms.TukeyBiweight, (4,), res_r.res_biweight),
]

dtypes = ["int", np.float64, np.complex128]
Expand Down

0 comments on commit 9b1c6d1

Please sign in to comment.