-
Notifications
You must be signed in to change notification settings - Fork 21
Adds CR3 estimator to lm_robust and iv_robust #263
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
base: main
Are you sure you want to change the base?
Conversation
nfultz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
| if (!is.null(obj[["call"]])) { | ||
| obj[["call"]] <- NULL | ||
| } | ||
| return(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rmcall <- function(obj) { structure(obj, call=NULL) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work as call is an object in a list not an attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - right, different from DeclareDesign. You can still remove the null check I think.
src/lm_robust_helper.cpp
Outdated
| } else { | ||
|
|
||
| if (se_type == "CR2") { | ||
| if (se_type == "CR2" || se_type == "CR3") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose if you want
((se_type == "CR2") || (se_type == "CR3"))
(se_type == "CR2" || se_type == "CR3")
(se_type %in% c("CR2", "CR3"))
and be consistent throughout.
|
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 ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/lm_robust_helper.cpp
<#263 (comment)>
:
> @@ -426,16 +428,30 @@ List lm_variance(Eigen::Map<Eigen::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
<#263 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMJO_Shg7vsyo5FFGicEwdjHvTCt-PGFks5uoMF-gaJpZM4X2uhQ>
.
|
|
@macartan, the tests compare it with clubSandwich. Stata does not have CR3 standard errors, but I think base |
|
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. |
|
OK with me if we just round to the 10th decimal place or something to get around this windows issue |
|
Thanks so much for adding this. |
lm_robustandiv_robust(closes issue Add CR3 clustered se option #261)