Skip to content

RLM supporting functions  #1372

Open
Open

Description

@josef-pkt

RLM norms define default parameters, but it's not clear how they are/were chosen.
SAS mentions that theirs are at 95% relative efficiency for normal model (except for Hampel and Welch). But they use 85% efficiency parameters in other examples, cases.

A helper function to calculate relative efficiency for given norm and parameters would be helpful in choosing those, or even as information for default values.
other possibility: can we get the influence function for a norm.

(I don't know how to calculate these two.

related: additional diagnostic plots, ... for RLM results

Activity

  1. josef-pkt commented on Feb 8, 2014

    @josef-pkt
    MemberAuthor

    Looks like relative efficiency is just the ratio of the asy Variance of RLM relative to the one of OLS.
    OLS variance is efficient under normality and iid asumption.

    The following is based on Maronna, Martin, Yohai for one-dimensional parameter, location case.
    Our covariance matrices H1 has a correction factor, H2, H3 have different form. The efficiency will be a little bit different.

    >>> M = rnorms.HuberT()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    0.950000259955174
    >>> M = rnorms.AndrewWave()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    0.9500413789611936
    >>> M=rnorms.TukeyBiweight()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    0.9499973500709455
    >>> M = rnorms.RamsayE()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    0.9637407524015408
    >>> M = rnorms.Hampel()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    0.9898103407903082
    

    this doesn't look right:

    >>> M = rnorms.TrimmedMean()
    >>> stats.norm.expect(M.psi_deriv)**2 / stats.norm.expect(lambda x: M.psi(x)**2)
    1.2336161088009268
    
  2. josef-pkt commented on Feb 11, 2014

    @josef-pkt
    MemberAuthor

    Note: the variance formula is different for norms that have a psi function with jumps.
    Because of the jumps we get mass points, and the variance depends on the underlying density at the jump point. see for example quantile regression (with kernel estimate for f(0) )

    partial reference: they mention it and have the formula without details
    Jureckova, Jana, and Jan Picek. Robust statistical methods with R. CRC Press, 2005.
    end of section 4.3.2 for fixed design matrix

    edit This might only be true for upwards jumps, Jureckova and Picek assume increasing psi function in this part.

  3. josef-pkt commented on Mar 11, 2024

    @josef-pkt
    MemberAuthor

    back to this again, relative efficiency and choice of tuning parameter

    working with Menenez et al 2021, issue #8808
    for a new norm #8808 (comment)

    def var_normal(norm):
        num = stats.norm.expect(lambda x: norm.psi(x)**2)
        denom = stats.norm.expect(lambda x: norm.psi_deriv(x))**2
        return num / denom
    

    eff = 1 / var_normal
    Note: var_normal for LeastSquares is 1.

    checking biweight, new Quartic and AndrewWave. Those are smooth, continuous second derivative, and only one parameter

    values for tuning parameter agree with Menenez et al.

    for eff in [0.9, 0.95, 0.98, 0.99]:
        print(eff, optimize.brentq(lambda c: var_normal(TukeyQuartic(c=c)) - 1/eff, 2, 5))
    0.9 3.157622747558112
    0.95 3.6175216332560893
    0.98 4.2102659017767445
    0.99 4.666379040076477
    
    # bisquare as special case
    for eff in [0.85, 0.9, 0.95, 0.98, 0.99]:
        print(eff, optimize.brentq(lambda c: var_normal(TukeyQuartic(c=c, k=2)) - 1/eff, 2, 8))
        
    # in de Menenez 3.8827, 4.6851, 5.9207, 7.0414 for eff in [0.9, 0.95, 0.98, 0.99]
    0.85 3.4436897830001634
    0.9 3.8826615796986195
    0.95 4.685064948349945
    0.98 5.920718988164744
    0.99 7.041391632164421
    ​
    for eff in [0.85, 0.9, 0.95, 0.98, 0.99]:
        print(eff, optimize.brentq(lambda c: var_normal(norms.AndrewWave(a=c)) - 1/eff, 0.1, 8))
    0.85 0.9883587537542797
    0.9 1.1117130177350114
    0.95 1.3387108441644708
    0.98 1.6930529162935126
    0.99 2.016967848151064
    

    Menenez et al have a description about how they chose tuning parameters if there are more than one parameters.
    e.g. for Hampel they tune a with the other two in a fixed relation: c = 4 * a and b = 2 * a.

    Also, they use a different variance formula that does not require psi_deriv and instead use derivative of pdf,
    eq. (16) referencing Hampel et al book 1986. That also works if psi_deriv has jumps.
    (I don't understand why that equivalence holds, but I have not checked the references for this.)

    not clear yet how to make this available to users.

    • tuning parameter names are not standardized, and we need a norm specific keyword for it (use kwargs internally?)
    • multiple parameters need additional restrictions
    • formula needs to change depending on presence of jumps in psi_deriv

    one possibility:

    • use private functions for the actual computation (without verifying underlying assumptions) and
    • class method in norms that returns tuning parameter for required relative efficiency and handles the norm specific parts.
    • also include cache/table for common efficiency values, e.g. for 0.80, 0.85, 0.90, 0.95, 0.98, 0.99.
    • other option (as in some cases in R functions): allow user to specify eff in Norm.__init__ as alternative to parameters and override those.

    This is only efficiency for univariate mean estimation including regression, M-estimators like RLM and two step/stage estimators that have M-estimator as final step, e.g. MM-estimators.
    M-estimators for scale or multivariate mean and covariance need different tuning parameters, formulas for relative efficiency differ from the univariate mean case.

    update
    I'm not sure anymore where the problem is, first or second derivative of rho.
    Norms like TrimmedMean or absolute value (check function as in median regression) have jump discontinuity in the first derivative already, while Hampel still has continuous psi function.
    The computation of cov_params requires a special case for kink at zero (or at minimum of rho function), e.g. quantile regression, LASSO-L1 cases.

    Menenez et al mention only psi_deriv discontinuity in description of relative efficiency.

    Aside: TrimmedMean is "Talwar", norm 43 in Menenez
    Using the jump version of var_normal, I get the same tuning parameters for TrimmedMean/Talwar as Menenez for the 4 efficiency levels that they have.

    update 2

    Hampel et al book 1986 p. 127 (Menenez referenced p.126)
    equ. (2.5.7) expectation of psi_deriv has an extra term for jump points of psi, set C, and not psi_deriv, set D.
    So it looks like we don't have an extra term if psi is continuous.
    If psi is continuous, then expectation of psi_deriv is integral of piecewise continuous function.
    (I never really learned calculus for non-continuous functions).

    It looks like TrimmedMean is the only function with discontinuous psi function.
    (I'm not sure anymore about MQuantileNorm, but AFAIR I looked at continuous psi cases.)

    Hampel don't explain that integral psi_deriv * pdf = integral psi * pdf_deriv but it looks like it follows from integration by parts.
    (definitive integral from -inf to +inf)
    update again
    Hampel et al equ. 2.3.8 has something similar but for influence function.
    However, instead of f' (derivative of pdf(y), they have derivative of pdf w.r.t. params, i.e. d f(y, theta) / d theta
    Maybe because in location model f(y - mu) we have d f / d mu = - d f /d y.
    (I'm just skimming and was looking for other things. I never read any complete chapter of Hampel et al. It's too theoretical for implementation.)

  4. added this to the 0.15 milestone on Mar 11, 2024
  5. josef-pkt commented on Mar 11, 2024

    @josef-pkt
    MemberAuthor

    related: checking current default efficiency
    relative efficiency of TrimmedMean is only 0.73853587. currently c=2. It should be c=2.7955 for 95% rel.eff.

    Will not be backwards comparible.

    Aside: TrimmedMean estimation should be same as LTS. I think I never checked.
    We should be able to verify variance comparing RLM-TrimmedMean with explicit LTS/ELTS implementation.

    Note: LTS trims fraction of observation. ELTS uses metric trimming in reweighting step.
    TrimmedMean is metric trimming, but we need trimming threshold c to correspond to normal tail trimming (ppf, c=stats.norm.isf(alpha/2)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions