estimatr icon indicating copy to clipboard operation
estimatr copied to clipboard

Adds CR3 estimator to lm_robust and iv_robust

Open lukesonnet opened this issue 7 years ago • 5 comments

  • Version bump for first post-0.12 release bump
  • Adds CR3 standard error estimators to both lm_robust and iv_robust (closes issue #261)
  • Updates documentation and tests (lots of test refactoring)
  • For now gives S-1 as the degrees of freedom, as the next PR will just divide the DoF from the SE

lukesonnet avatar Oct 23 '18 21:10 lukesonnet

Luke -- has it be possible to check this implementation against others in R or stata?

On Wed, Oct 24, 2018 at 3:37 PM Luke Sonnet [email protected] wrote:

@lukesonnet commented on this pull request.

In src/lm_robust_helper.cpp https://github.com/DeclareDesign/estimatr/pull/263#discussion_r227931837 :

@@ -426,16 +428,30 @@ List lm_variance(Eigen::MapEigen::MatrixXd& X, H2s.block(0, p_pos, r_fe, r_fe) = ME * X.block(start_pos, 0, len, r_fe) * M_U_ct; H3s.block(0, p_pos, r_fe, r_fe) = MEU * Omega_ct; }

  •      } else if (se_type == "CR3") {
    
  •        Eigen::CompleteOrthogonalDecomposition<Eigen::MatrixXd> At(
    
  •            Eigen::MatrixXd::Identity(len, len) -
    
  •              Xoriginal.block(start_pos, 0, len, r_fe) *
    
  •              meatXtX_inv *
    
  •              X.block(start_pos, 0, len, r_fe).transpose()
    
  •        );
    
  •        if (Xunweighted.isNotNull()) {
    
  •          At_WX_inv =  At.solve(Eigen::MatrixXd::Identity(len, len)).transpose() * X.block(start_pos, 0, len, r_fe);
    

It doesn't know the solution is symmetric, so the transpose is not a no-op, right?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DeclareDesign/estimatr/pull/263#discussion_r227931837, or mute the thread https://github.com/notifications/unsubscribe-auth/AMJO_Shg7vsyo5FFGicEwdjHvTCt-PGFks5uoMF-gaJpZM4X2uhQ .

macartan avatar Oct 24 '18 21:10 macartan

@macartan, the tests compare it with clubSandwich. Stata does not have CR3 standard errors, but I think base sandwich in R does now and I could add those tests.

lukesonnet avatar Oct 24 '18 22:10 lukesonnet

I'm stuck right now because the slight (numerical) differences in the variance-covariance matrix from commarobust or from lm_robust are causing different kinds of failures in computing the F-statistic on windows 32bit machines.

This is an absolutely ridiculous error, but I'm trying to eliminate or minimize the numerical deviations that are causing it.

lukesonnet avatar Oct 24 '18 22:10 lukesonnet

OK with me if we just round to the 10th decimal place or something to get around this windows issue

acoppock avatar Oct 30 '18 15:10 acoppock

Thanks so much for adding this.

acoppock avatar Oct 30 '18 15:10 acoppock