Skip to contents

Calculate confidence intervals of proportion or difference between proportions in a data.frame

Usage

propCI_sub(data, x, y = NULL)

Arguments

data

A data.frame

x

Character Name of a categorical column

y

Character Optional. Name of another categorical column

Value

A list containing at least the following components:

data

A tibble containing raw data or a list of numeric vector

result

A data.frame consists of summary statistics

call

the matched call

attr(*,"measure")

character. One of c("prop","propdiff")

Examples

propCI_sub(acs,"sex")
#> $data
#> # A tibble: 857 × 1
#>    value 
#>    <chr> 
#>  1 Male  
#>  2 Female
#>  3 Female
#>  4 Female
#>  5 Male  
#>  6 Female
#>  7 Male  
#>  8 Male  
#>  9 Female
#> 10 Male  
#> # … with 847 more rows
#> 
#> $result
#>   alpha   n  df         p P         se critical         ME     lower     upper
#> 1  0.05 857 856 0.6651109 0 0.01612156 1.959964 0.03159768 0.6335132 0.6967085
#>                       CI        z pvalue alternative
#> 1 0.67 [95CI 0.63; 0.70] 41.25598      0   two.sided
#> 
#> $call
#> propCI(x = data[[x]])
#> 
#> attr(,"measure")
#> [1] "prop"
propCI_sub(acs,"sex","HBP")
#> $data
#> # A tibble: 857 × 2
#>    x      y    
#>    <chr>  <chr>
#>  1 Male   No   
#>  2 Female Yes  
#>  3 Female Yes  
#>  4 Female No   
#>  5 Male   Yes  
#>  6 Female Yes  
#>  7 Male   Yes  
#>  8 Male   Yes  
#>  9 Female Yes  
#> 10 Male   No   
#> # … with 847 more rows
#> 
#> $result
#>   alpha        p1        p2  n1  n2   DF        pd         se critical
#> 1  0.05 0.7108014 0.5210526 857 857 1712 0.1897488 0.02304477 1.959964
#>           ME     lower     upper                     CI  ppooled   sepooled
#> 1 0.04516692 0.1445818 0.2349157 0.19 [95CI 0.14; 0.23] 0.615927 0.02349612
#>         z       pvalue alternative
#> 1 8.07575 6.706325e-16   two.sided
#> 
#> $call
#> propCI(x = data[[x]], y = data[[y]])
#> 
#> attr(,"measure")
#> [1] "propdiff"