Skip to content

f_value OLS WLS don't match #1212

Open
Open

Description

@josef-pkt

I'm writing tests between WLS and OLS with user-weighting. in PR #1189

The fvalues differ. Should they?

second part: When I use robust covariances (HC1), the fvalue also differ, even though the cov_params is the same. The only difference in the code can come from the constant detection.
There must be something strange or not robust there.

I'm using one of the exog as weights (inverse: weights=exog[...])

Activity

  1. jseabold commented on Nov 28, 2013

    @jseabold
    Member

    Yes. Recall the weighted centered vs. uncentered sum of squares bug.

  2. josef-pkt commented on Nov 28, 2013

    @josef-pkt
    MemberAuthor

    Is there an issue or an explanation somewhere?

    I didn't check whether I could turn of the constant detection in my example.
    I thought maybe because exog[] * weight = 1, but the OLS rescaling is with the sqrt(weights), so maybe that's not it, or it goes the other way.

    I just tried: adding hasconst=True to the weighted OLS doesn't help, but it breaks the fvalue calculation in non-robust because const_idx is None

  3. jseabold commented on Nov 28, 2013

    @jseabold
    Member
  4. josef-pkt commented on Nov 28, 2013

    @josef-pkt
    MemberAuthor

    Thanks, it will take me some time to understand that, when I have or take the time.

    I have a problem in my code (fvalue) and plans where I wanted to replace comparing sum of squares with wald test, if we don't have an identified constant, i.e. const_idx is None.

    IIRC, Kevin uses projection (on a constant?) in one of his PR to get the difference to constant or restriction matrix, or something like that.

  5. bashtage commented on Nov 28, 2013

    @bashtage
    Member

    That is the only method I know to test for an implicit constant, although in my example I first do a simple boolean test (could also test dummies, but not sure how to always get it correct). Basically test whether the R^2 is 1 of regressing a column of 1s on the same X - should be relatively low cost since pinv has been computed.

  6. josef-pkt commented on Nov 29, 2013

    @josef-pkt
    MemberAuthor

    Yes, I thought it's a nice way of checking this when I saw it and kept it in mind for other things.
    Related: for 1st stage of 2SLS, I thought of using residuals==0 (relative tolerance 1e-13 or so) to check for which exog are really exogenous (i.e. both included in explanatory variables and included in instruments.)

    Can we recover the restriction matrix for testing beta=0 except for the implied constant?
    I think there is related code in contrasts that we inherited that I never figured out in detail.

    Coming back to the fvalue, we can use the f_test if we have the restriction matrix relative to just a model with a constant, or use f_test for all params=0 if there is no constant.

    In discrete we also use the Lagrange multiplier test in the summary() comparing to a model with only a constant.
    This will also need to be replaced with a Wald test if we use robust covariances, in QML, AFAICS.

  7. bashtage commented on Dec 1, 2013

    @bashtage
    Member

    I would probably do an all comparrison since it is reasonable to assume that if a variable is in both the regressors and exogenous variables, then it will appear without any modification. This should be faster, especially if there are a lot of variables.

    The only advantage of using a residual-based test would be to protect against end-users doing silly things, like rotating their exogenous variables.

    As for recovering in the case of an explicit restriction, you can coefficients on a vector of 1, and the regression coefficients tell you the null (up to a scale that doesn't matter). For example, if you estiamted b=(0,.3,.7), then .3 * x2 + .7_x1 = 1, so the null is 0_b1=.3_b2 = .7_b3, or the restriction matrix is R=[0 .3 -.7], r=1. The number of restrictions for the intercept is equal the the number of non-zero coefficients minus 1.

    f_test is technically fine if there is no constant, although it is important to use a SSE-based version and not an R2 versions since R2 definition changes (SSE doesn't). Easy to verify by simulation.

  8. jseabold commented on Sep 21, 2014

    @jseabold
    Member

    I don't think this is an issue. Re-open if necessary.

  9. josef-pkt commented on Sep 23, 2014

    @josef-pkt
    MemberAuthor

    Check whether this works for the case when also WLS doesn't have a constant.

    AFAICS now, OLS with reweighted endog and exog doesn't have enough information to do a proper f_test.
    At least in the case of Wald test there is no implicit constant in the model. The constant would be
    1 * weights.

    However, I'm opening a new issue for f_test or wald_test against an implicit constant. That case (hasconstant=True, but no explicit constant) fails currently in the robust covariances which use the f_test.

  10. added this to the 0.7 milestone on Sep 23, 2014
  11. modified the milestones: 0.8, 0.7 on Feb 15, 2015
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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions