[R] why does lm() not allow for negative weights?

Jens Hainmueller jhainm at fas.harvard.edu
Fri Aug 4 19:26:49 CEST 2006


Dear List,

Why do commonly used estimator functions (such as lm(), glm(), etc.) not
allow negative case weights? I suspect that there is a good reason for this.
Yet, I can see reasonable cases when one wants to use negative case weights.

Take lm() for example:

###

n <- 20
Y <- rnorm(n)
X <- cbind(rep(1,n),runif(n),rnorm(n))
Weights <- rnorm(n)
# Includes Pos and Neg Weights
Weights

# Now do Weighted LS and get beta coeffs:
b <- solve(t(X)%*%diag(Weights)%*%X) %*% t(X) %*% diag(Weights)%*%Y
b

# This seems like a valid model, but when I try
lm(Y ~ X[,2:3],weights=Weights)

# I get: "missing or negative weights not allowed"

###

What is the rationale for not allowing negative weights? I ask this, because
I am currently trying to implement a (two stage) estimator into R that
involves negative case weights. Weights are generated in the first stage, so
it would be nice if I could use canned functions such as
lm(,weights=Weights) in the second stage.

Thank you for your help.

Best,
Jens



More information about the R-help mailing list