Description Usage Arguments Value Examples
View source: R/compare_margins.R
Inspect by what degree the unweighted or weighted sample proportions deviate from the target proportions.
1 | compare_margins(universe, data, weight, plot = FALSE)
|
universe |
Full weighting design created by |
data |
Data frame that includes weight from |
weight |
Name of weight variable in optional |
plot |
Display plot, default = FALSE. |
A tibble of unweighted counts and proportions, difference between
unweighted and target proportions. If `data`
and `weight`
is given, it also includes
weighted counts and proportions, difference between weighted and target proportions.
Optionally, a plot of this information.
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 39 40 41 42 43 44 45 46 47 48 49 | data(demo_data)
mod <- 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)
)
)
compare_margins(
universe = mod,
plot = TRUE
)
wgts <- iterake(
universe = mod
)
compare_margins(
universe = mod,
data = wgts,
weight = weight,
plot = FALSE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.