senate_weights: senate_weights() computes senate weights. These weights are...

View source: R/senate_weights.R

senate_weightsR Documentation

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.

Description

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

Details

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

Value

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

Examples

library(dplyr)
data_frame_with_weights <- data_frame %>%
                           r4sda::senate_weights(.,
                           scale = 1000,
                           wt = 'wt',
                           id_k = 'id_k')

dacarras/r4sda documentation built on Nov. 9, 2023, 10:17 a.m.