Skip to contents

senate_weights() computes senate weights. These weights are used often to include more than one country with different sample size, yet to scale their weight to a common total.

Usage

senate_weights(data, wt, scale, id_k)

Arguments

data

data frame object which contains the rest of the arguments

wt

observations final weight

scale

number to which the weights will be normalized to

id_k

a numeric vector of a single variable, to distinguish between countries

Value

the original data frame with the new senate weights at the end, 'ws'

Details

a collection of dplyr::mutate sequences to create normalized and effective sample weights (see Rabe-Hesketh & Skrondal, 2006; Snijder & Bosker, 2012)

Examples

library(dplyr)
#> Error in library(dplyr): there is no package called ‘dplyr’
data_frame_with_weights <- data_frame %>%
                           r4sda::senate_weights(.,
                           scale = 1000,
                           wt = 'wt',
                           id_k = 'id_k')
#> Error in data_frame %>% r4sda::senate_weights(., scale = 1000, wt = "wt",     id_k = "id_k"): could not find function "%>%"