-
Notifications
You must be signed in to change notification settings - Fork 13
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
Instrument weights #42
base: main
Are you sure you want to change the base?
Conversation
@@ -128,16 +128,14 @@ twosls <- function(y, X, W, intercept = FALSE, lm.type = "lm"){ | |||
|
|||
if(intercept) { | |||
model <- switch(lm.type, | |||
"lm" = lm(y ~ Xhat), | |||
"lm.fit" = lm.fit(cbind(1, Xhat), y), | |||
".lm.fit" = .lm.fit(cbind(1, Xhat), y)) |
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.
I wasn't sure how to weight ".lm.fit". I don't see the ".lm.fit" option being used, and this function isn't exported, so I just deleted it?
if (! is.numeric(w)) stop("'weights' must be a numeric vector") | ||
if (any(w < 0) || anyNA(w)) stop("missing or negative weights not allowed") | ||
X <- X * sqrt(w) | ||
y <- y * sqrt(w) |
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.
Delete this because I used lm to weight below and don't want to weight twice.
# also: RE bvk/BE/FE IV do not have weighting code. | ||
if (inst.method == "baltagi") W <- sqrt(w) * cbind(W1, W2, B1) | ||
if (inst.method == "am") W <- sqrt(w) * cbind(W1, W2, B1, StarW1) | ||
if (inst.method == "bms") W <- sqrt(w) * cbind(W1, W2, B1, StarW1, StarW2) |
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.
Delete weights because I used lm to weight below and don't want to weight twice
No idea if I did this right. Closes #41.