Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy.survreg function fails when robust = T in survreg model #728

Closed
poppymiller opened this issue Jul 24, 2019 · 3 comments · Fixed by #842
Closed

tidy.survreg function fails when robust = T in survreg model #728

poppymiller opened this issue Jul 24, 2019 · 3 comments · Fixed by #842
Labels
bug an unexpected problem or unintended behavior

Comments

@poppymiller
Copy link

Error when using robust regression in survreg. I think the issue is that robust regression gives a summary table with an extra column (called "(Naive SE)").

fmla <- as.formula(paste("Surv(time, status) ~ ","karno + age" ))
fit <- survreg(formula = fmla, data = veteran, dist = "lognormal", robust = T)
broom::tidy(fit)

summary(fit)$table

I propose changing the tidy.survreg function as follows to fix this error

  tidy.survreg <- function(x, conf.level = .95, conf.int = FALSE, ...) {
  s <- summary(x)
  # add extra column name here
  nn <- c("estimate", "std.error", "(Naive SE)", "statistic", "p.value")
  ret <- fix_data_frame(s$table, newnames = nn)
  
  if(conf.int){
    # add confidence interval
    ci <- stats::confint(x, level = conf.level)
    colnames(ci) <- c("conf.low", "conf.high")
    ci <- fix_data_frame(ci)
    ret <- as_tibble(merge(ret, ci, all.x = TRUE, sort = FALSE))
  }
  
  ret
  }
@alexpghayes alexpghayes added the bug an unexpected problem or unintended behavior label Aug 7, 2019
@IndrajeetPatil
Copy link
Contributor

@poppymiller Do you want to make a PR to implement the change you have suggested here?

@karldw
Copy link
Contributor

karldw commented Mar 2, 2020

@IndrajeetPatil, I just tripped on this too. It would be great to fix, though I think the code needs to handle both cases, with and without the extra column. I can write a PR in a few months if no one gets to it before then.

simonpcouch added a commit that referenced this issue May 21, 2020
drop the `Naive SE` column when `robust = TRUE` in `tidy.survreg()`
@github-actions
Copy link

github-actions bot commented Mar 8, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants