-
Notifications
You must be signed in to change notification settings - Fork 130
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
Feature request: deff for tbl_svy_summary()
#1486
Comments
larmarange
added a commit
to larmarange/gtsummary
that referenced
this issue
Apr 11, 2023
15 tasks
Could you have a look at #1487 It adds library(gtsummary)
#> #Uighur
data(api, package = "survey")
d <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
d %>%
tbl_svysummary(
by = both,
include = full,
statistic = all_continuous() ~ "{mean} ({deff})"
) %>%
add_overall() %>%
as_kable()
d %>%
tbl_svysummary(
by = both,
include = stype,
statistic = all_categorical() ~ "{p}% ({deff})"
) %>%
add_overall() %>%
as_kable()
d %>%
tbl_svysummary(
by = both,
include = stype,
percent = "row",
statistic = all_categorical() ~ "{p}% ({deff})"
) %>%
add_overall() %>%
as_kable()
d %>%
tbl_svysummary(
by = both,
include = stype,
percent = "cell",
statistic = all_categorical() ~ "{p}% ({deff})"
) %>%
add_overall() %>%
as_kable()
Created on 2023-04-11 with reprex v2.0.2 |
Note: design effects are computed using |
ddsjoberg
added a commit
that referenced
this issue
Apr 15, 2023
* `tbl_svysummary()` can now report design effects fix #1486 * updates to testing file * snap update * increment version number * Update DESCRIPTION * snapshot update --------- Co-authored-by: Daniel Sjoberg <danield.sjoberg@gmail.com>
sorry for the delay - this looks perfect thanks so much for the speedy implementation! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
Hello! It would be really useful for surveys if we could report the design effect using
tbl_svy_summary()
.This is useful because it can then be used to calculate the intra-class correlation coefficient - which can be used in future surveys to calculate the sample size required. (detail in additional context). Thanks so much!
Describe the solution you'd like
An
add_deff()
function would be nice - though I feel it might also fit withinadd_ci()
given that this already calls the appropriate {survey} functions.Describe alternatives you've considered
It would be possible to use
tbl_svysummary_custom()
once up to wrap some of the code discussed here . Alternatively it might be possible to useadd_stat()
pulling the se from the existing table body. But both of those seem really messy for end-users and deff reporting is pretty common practice.Additional context$deff$ ). This compares the variance
To account for the additional variability at the different stages of
complex designs, the sample size and sample estimates can be adjusted by
a factor known as the design effect (
(i.e. the square of the Standard Error (SE)) of estimates from the more
complex design used, to the variance that would come from the same
sample size if simple random sampling had been used.
For cluster sampling, the variance can be calculated with the following
formula:
where:
vaccination coverage)
school classes in this study)
school classes in the whole country)
The design effect can then be calculated by:
The sample size will increase by the amount of the design effect. For
example, if the design effect is estimated as 1.5, this means that in
order to obtain the same precision, 50% more individuals must be studied
with the complex design than with the simple random sampling strategy.
the design effect can also be calculated$rho$ :
with the intra-cluster correlation coefficient, or
where:
homogeneity for the outcome of interest.
The text was updated successfully, but these errors were encountered: