Skip to content

Conversation

@bramtayl
Copy link

No idea if I did this right. Closes #41.

model <- switch(lm.type,
"lm" = lm(y ~ Xhat),
"lm.fit" = lm.fit(cbind(1, Xhat), y),
".lm.fit" = .lm.fit(cbind(1, Xhat), y))
Copy link
Author

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)
Copy link
Author

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)
Copy link
Author

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Help with weights for instrumental variable regression

1 participant