weight_stats: Generate summary statistics for a set of weights

Description Usage Arguments Value Examples

View source: R/weight_stats.R

Description

This function creates a tibble containing information pertaining to a set of weights. It includes sample size, weighted sample size, effective sample size, as well as loss and efficiency values.

Usage

1
weight_stats(weight)

Arguments

weight

Single column of a data frame or vector of weights.

Value

A tibble containing unweighted and weighted sample size, effective sample size, and efficiency and loss values for the supplied weight data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
data(demo_data)

wgts <- 
  iterake(
    universe = universe(
        data = demo_data,
        
        category(
            name = "Sex",
            buckets = factor(
                x = levels(demo_data[["Sex"]]),
                levels = levels(demo_data[["Sex"]])
            ),
            targets = c(0.4, 0.5),
            sum.1 = TRUE
        ),

        category(
            name = "BirthYear",
            buckets = c(1986:1990),
            targets = rep(0.2, times = 5)
        ),
    
        category(
            name = "EyeColor",
            buckets = c("brown", "green", "blue"),
            targets = c(0.8, 0.1, 0.1)
        ),
    
        category(
            name = "HomeOwner",
            buckets = c(TRUE, FALSE),
            targets = c(3/4, 1/4)
        )
    )
  )

weight_stats(wgts$weight)

ttrodrigz/iterake documentation built on July 1, 2020, 7:46 a.m.