Skip to contents

A version of survey::svyciprop() that adjusts for the degrees of freedom when method = "beta".

Usage

svyciprop_adjusted(
  formula,
  design,
  method = c("logit", "likelihood", "asin", "beta", "mean", "xlogit"),
  level = 0.95,
  df_method,
  ...
)

Arguments

formula

see survey::svyciprop().

design

see survey::svyciprop().

method

see survey::svyciprop().

level

see survey::svyciprop().

df_method

how df should be calculated: "default" or "NHIS".

...

see survey::svyciprop().

Value

The point estimate of the proportion, with the confidence interval as an attribute.

Details

Written by Makram Talih in 2019.

df_method: for "default", df = degf(design); for "NHIS", df = nrow(design) - 1.

To use this adjustment in surveytable tabulations, call set_survey() or set_opts() with the mode = "NCHS" argument, or type: options(surveytable.adjust_svyciprop = TRUE). NHIS users, be sure to set the surveytable.adjust_svyciprop.df_method option to "NHIS".

Examples

set_survey(namcs2019sv)
#>                         Survey info {NAMCS 2019 PUF}                         
#> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
#> │ Variables │ Observations │ Design                                         │
#> ├───────────┼──────────────┼────────────────────────────────────────────────┤
#> │        33 │        8,250 │ Stratified 1 - level Cluster Sampling design   │
#> │           │              │ (with replacement)                             │
#> │           │              │ With (398) clusters.                           │
#> │           │              │ namcs2019sv = survey::svydesign(ids = ~CPSUM,  │
#> │           │              │ strata = ~CSTRATM, weights = ~PATWT            │
#> │           │              │ , data = namcs2019sv_df)                       │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#> 
set_opts(mode = "NCHS")
#> * Mode: NCHS.
tab("AGER")
#>                                 Patient age recode {NAMCS 2019 PUF}                                 
#> ┌─────────────┬───────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐
#> │ Level       │     n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │
#> │             │       │       (000) │          │          │          │         │     │      │      │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ Under 15    │   887 │     117,917 │   14,097 │   93,229 │  149,142 │    11.4 │ 1.3 │  8.9 │ 14.2 │
#> │ years       │       │             │          │          │          │         │     │      │      │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 15-24 years │   542 │      64,856 │    7,018 │   52,387 │   80,292 │     6.3 │ 0.6 │  5.1 │  7.5 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 25-44 years │ 1,435 │     170,271 │   13,966 │  144,925 │  200,049 │    16.4 │ 1.1 │ 14.3 │ 18.8 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 45-64 years │ 2,283 │     309,506 │   23,290 │  266,994 │  358,787 │    29.9 │ 1.4 │ 27.2 │ 32.6 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 65-74 years │ 1,661 │     206,866 │   14,366 │  180,481 │  237,109 │    20   │ 1.2 │ 17.6 │ 22.5 │
#> ├─────────────┼───────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 75 years    │ 1,442 │     167,069 │   15,179 │  139,746 │  199,735 │    16.1 │ 1.3 │ 13.7 │ 18.8 │
#> │ and over    │       │             │          │          │          │         │     │      │      │
#> └─────────────┴───────┴─────────────┴──────────┴──────────┴──────────┴─────────┴─────┴──────┴──────┘
#>   N = 8250. Checked NCHS presentation standards. Nothing to report.                                 
#> 
set_opts(mode = "general")
#> * Mode: General.