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

Bug Report: Mismatched estimates and CIs with add_ci after tbl_svysummary #2052

Closed
louisahsmith opened this issue Oct 30, 2024 · 2 comments · Fixed by #2057
Closed

Bug Report: Mismatched estimates and CIs with add_ci after tbl_svysummary #2052

louisahsmith opened this issue Oct 30, 2024 · 2 comments · Fixed by #2057

Comments

@louisahsmith
Copy link

When adding confidence intervals to a table created with tbl_svysummary() that is stratified by a factor variable, the confidence intervals can get attached to the wrong column. This seems to be related to #2036 but is not fixed in version 2.0.3.9003.

data(api, package = "survey")

survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) |>
    tbl_svysummary(by = "both", include = c(stype)) |>
    add_ci(pattern = "{stat} ({ci})")

apiclus1 <- apiclus1 |> mutate(both2 = factor(both, levels = c("Yes", "No")))

survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) |>
    tbl_svysummary(by = "both2", include = c(stype)) |>
    add_ci(pattern = "{stat} ({ci})")
@ddsjoberg
Copy link
Owner

ddsjoberg commented Nov 3, 2024

Thank you so much for the report and including a reproducible example, much appreciated. Can you install the dev version of {cardx} and try again? devtools::install_remote("insightsengineering/cardx@restore-types"). That branch is still a work in progress, but I think it should address this issue.

@louisahsmith
Copy link
Author

That seems to have fixed it! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants