2

I am running quantile regression (package quantreg) and using texreg to create a latex output of my models.

I am interested in bootstrapped s.e. and set se="boot" in the options of summary but when I use texreg I get "n.i.d." s.e.

How do I change that option?

Here is what I am doing:

tm3 <- rq(nback ~ cara + mat + dut + e_brown + e_green + e_blue + ins_no + ins_1
          + ins_5 + lit + sci + lan + gender_f + partner,  
          tau = 0.75, data=tru_all, model=TRUE)
summary(tm3, se = "boot")
texreg(tm3)

I tried looking into texreg (typing texreg on the console) and at lines 35-38 I found

for (i in 1:length(models)) {
cf <- models[[i]]@coef
se <- models[[i]]@se
pv <- models[[i]]@pvalues

How do I set the s.e. method? I have never changed R functions, if that is what I need to do can you suggest a link that explains how to do it?

lmo
  • 37,904
  • 9
  • 56
  • 69
user1841739
  • 31
  • 1
  • 2
  • The issue isn't in `texreg` it's in the extract method `extract.rq`, which doesn't appear to allow for passing arguments on to `summary.rq`. My initial attempts to modify `extract.rq` haven't been very fruitful. Perhaps someone else will have more luck. – joran Nov 21 '12 at 15:52

2 Answers2

1

Partial success. I'm not so adept with S4 classes, but I was able to get something working by downloading the package source, and editing the first few lines of extract.rq to:

extract.rq <- function(model, include.nobs=TRUE, include.percentile=TRUE,...) {
  co <- summary(model, cov=TRUE,...)$coef[,1]
  names <- rownames(summary(model, cov=TRUE,...)$coef)
  se <- summary(model, cov=TRUE,...)$coef[,2]
  pval <- summary(model, cov=TRUE,...)$coef[,4]

  n <- length(summary(model,...)$resid)
  tau <- summary(model,...)$tau

Then building and installing the package from the modified sources appears to work, as in:

library(quantreg)
library(texreg)
data(stackloss)
m <- rq(stack.loss ~ stack.x,.5)

texreg(m,se = "boot")
texreg(m,se = "iid")
joran
  • 169,992
  • 32
  • 429
  • 468
  • Thank you @joran, butcan you point out exactly what you changed? I downloaded the package source (texreg.tar.gz), open it and looked for extract.rq, but the code looks already like the one you pasted...maybe I am just tired and am missing something – user1841739 Nov 21 '12 at 17:13
  • @user1841739 In the source files I downloaded, in `extract.R` the first few lines of the function `extract.rq` do not include the `...` arguments to `summary`. – joran Nov 21 '12 at 17:15
  • Got it! Thanks! I am now trying to build and install the package...would it be too much to ask how I should I go about it? :-) – user1841739 Nov 21 '12 at 17:22
  • Most painless way would be to use Rstudio's built-in Build+Reload functionality. Also, see [here](https://r-forge.r-project.org/forum/forum.php?thread_id=20576&forum_id=4325&group_id=1420) for an option that probably doesn't involve rebuilding the package using `setMethod`. – joran Nov 21 '12 at 17:29
1

I have updated the texreg source code. Your suggestion with the "..." argument should be implemented in the next release. If you have more suggestions, you may want to post them in the texreg forum.

Best, Philip

Philip Leifeld
  • 2,253
  • 15
  • 24