5
$\begingroup$

I am trying to implement quantile regression with sampling weights in R for my analysis. I know in lm() and glm() in R, standard errors, and hence confidence intervals, would not be estimated accurately with the option “weights =” since it assumes precision weights, and the survey package should be used instead. However, I cannot understand from the documentation whether that applies to rq() command for quantile regression as well, so whether the option “weights=” in rq() assumes precision weights only. Does anyone know?

I only found one resource applying quantile regression in R for survey data: the paper “Estimation of regression quantiles in complex surveys with data missing at random: An application to birthweight determinants”. It uses the following code :

mydesign <- svydesign(ids=~mycluster, strata=~mystrata, fpc=~myfpc, 
                      data=mydata, nest=TRUE, weights=~myweights)
bootdesign <- as.svrepdesign(mydesign, type="bootstrap", replicates=100)
fit <- withReplicates(bootdesign, quote(coef(rq(y ~ x, tau=0.5, weights=.weights, 
                                               method="fn"))))

The resulting fitted object fit contains the estimated regression coefficients and their bootstrap variances. This object can be then passed to the following custom-defined function to produce a summary table, including p values:

format.rq.svy <- function(x, rdf) {
  V <- attr(x, "var")
  FLAG <- length(V) == 1
  se <- if (FLAG) sqrt(V) else sqrt(diag(V))
  val <- cbind(as.matrix(x), se, NA, NA)
  if (FLAG) val <- matrix(val, nrow=1)
  val[, 3] <- val[, 1]/val[, 2]
  val[, 4] <- 2*(1 - pt(abs(val[, 3]), rdf))
  colnames(val) <- c("Value", "Std. Error", "t value", "Pr(>|t|)")
  rownames(val) <- names(x)
  return(val)
}

where the argument "rdf" specifies the residual degrees of freedom (i.e. n - q) for approximate p value calculation using t-distributions.

I am not sure how to specify the residual degrees of freedom. Is there a way to understand how many I should specify?

$\endgroup$

1 Answer 1

4
$\begingroup$

The weights in rq work like frequency weights, so you get the right point estimates. Using withReplicates will then get you weighted bootstrap confidence intervals, and these will be valid if weighted bootstrap confidence intervals for quantile regression are valid.

I don't know of any actual published proof that they are, but they should be*, for large enough sample size and not-too-extreme quantiles. In the unweighted setting, bootstrap confidence intervals are valid for large enough sample size and not-too-extreme quantiles.

The traditional value for residual df is degf(design) minus the number of parameters estimated. That probably underestimates the variability in standard errors, but there isn't a much better choice conveniently available.

$\endgroup$
4
  • $\begingroup$ Thank you very much for your answer! My sample size is not too large (459 obs), would weighted bootstrap confidence intervals still be ok? Or are there any other alternatives to estimate quantile regression in R with sampling weights? Many thanks for your help $\endgroup$
    – Cate
    Commented Jun 28 at 12:52
  • $\begingroup$ If the bootstrap doesn't work then I don't think anything else will do better $\endgroup$ Commented Jun 30 at 22:37
  • $\begingroup$ Hi, thanks again for your reply! In the example of the code above where "bootdesign" is used when running quantile regression, the degrees of freedom for the model should be estimated for the "bootdesign" instead of "design" in theory? (i.e. applying degf(bootdesign) minus the number of parameters estimated , instead of degf(design) minus the number of parameters estimated.) $\endgroup$
    – Cate
    Commented yesterday
  • $\begingroup$ @Cate that makes sense. I am not aware of any theoretical study of the question. $\endgroup$ Commented yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.