weighted_cgm: weighted_cgm() computes the grand mean centering, while...

View source: R/weighted_cgm.R

weighted_cgmR Documentation

weighted_cgm() computes the grand mean centering, while including normalized survey weights

Description

weighted_cgm() computes the grand mean centering, while including normalized survey weights

Usage

weighted_cgm(data, variable, weight, name)

Arguments

data

a data frame with variables ws (normalized survey weight), and id_k (higher cluster, e.g., country)

variable

variable to be center

weight

normalized survey weight

name

acronym for the generated variables

Value

a data frame, including the center variables

Examples

library(dplyr)
data_model %>%
weighted_cgm(data = ., variable = sex , weight = ws, name = sex) %>%
dplyr::glimpse()

dacarras/r4sda documentation built on Oct. 16, 2024, 9:13 a.m.