universe: Create universe

Description Usage Arguments Value Examples

View source: R/universe.R

Description

Along with the data to be weighted, this combines one or more objects of class category to build the universe with known marginal proportions. It also checks and adjusts the proportions to account for missing values in the data.

Usage

1

Arguments

data

Data frame containing data where weights are desired.

...

One or more output objects from category().

N

Size of universe. If supplied, expansion factor will be applied to weights after convergence.

Value

A list with special class universe.

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
data(demo_data)

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)
    )
)

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