[R] Using weights with truncreg

Ganz, Carl carlganz at ucla.edu
Mon Jun 13 19:45:49 CEST 2016


Hello everyone,

I would like to use truncreg on survey data with weights, but so far as I can tell the weight parameter in truncreg is not working. I find that using weights does not actually change the output.

Here is a small reproducible example using the example in the documentation:

## simulate a data.frame
set.seed(1071)
n <- 10000
sigma <- 4
alpha <- 2
beta <- 1
x <- rnorm(n, mean = 0, sd = 2)
eps <- rnorm(n, sd = sigma)
y <- alpha + beta * x + eps
d <- data.frame(y = y, x = x)

## truncated response
d$yt <- ifelse(d$y > 1, d$y, NA)

## binary threshold response
d$yb <- factor(d$y > 0)

## censored response
d$yc <- pmax(1, d$y)

## random weight
wgt <- runif(10000,500,1500)
## unweighted
fm_trunc <- truncreg(yt ~ x, data = d, point = 1, direction = "left")
## weighted
fm_trunc_weighted <- truncreg(yt ~ x, data = d, weights = wgt, point = 1, direction = "left")

coef(fm_trunc_weighted)==coef(fm_trunc) # all equal

Am I misunderstanding how the weight parameter works for truncreg or is the weight parameter not working?

Kind Regards,
Carl

	[[alternative HTML version deleted]]



More information about the R-help mailing list