Skip to content
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

bug in robust.scale.mad? #1106

Closed
cossatot opened this issue Oct 9, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@cossatot
Copy link

commented Oct 9, 2013

I believe there is a bug in the median absolute deviation function.

The code (def mad, lines 17-37 in statsmodels.robust.scale.py) appears to simply calculate the median of an array, scale it by the normalization constant, and return that. I.e. there is no step of dividing the array by the median.

The entire code is:

def mad(a, c=Gaussian.ppf(3/4.), axis=0): # c \approx .6745
    a = np.asarray(a)
    return np.median((np.fabs(a))/c, axis=axis)

and should be at least:

def mad(a, c=Gaussian.ppf(3/4.), axis=0): # c \approx .6745
    a = np.asarray(a)
    d = np.median(a)
    return np.median((np.fabs(a - d))/c, axis=axis)

I am happy to submit a PR, assuming that I am not wrong, but since I'm not previously a contributor I would ask for permission before doing so...

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Oct 9, 2013

duplicate of #658

@jseabold

This comment has been minimized.

Copy link
Member

commented Oct 9, 2013

Closing. Let's continue discussion on the other issue.

@jseabold jseabold closed this Oct 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.