lsa_weights | R Documentation |
lsa_weights() computes normalized and effective sample size weights for pseudo maximum likelihood mixed models, with large scale assessment data
lsa_weights(data, id_i, id_j, id_k, wt, wi, wj)
data |
data frame object which contains the rest of the arguments |
id_i |
a numeric vector of a single variable |
id_j |
a numeric vector of a single variable |
id_k |
a numeric vector of a single variable |
wt |
observations final weight |
wi |
observations weigth within the primary sampling unit (i.e. students eight within the school) |
wj |
cluster weights (i.e. school weights) |
a collection of dplyr::mutate sequences to create normalized and effective sample weights (see Rabe-Hesketh & Skrondal, 2006; Snijder & Bosker, 2012)
the original data frame with the new weights at the end, where 'wa1' and 'wa2' are level 1 and level 2 normalized weights; 'wb1' and 'wb2' are level 1 and level 2 effectives sample weights.
library(dplyr)
data_frame_with_weights <- erce::erce_2019_qa6 %>%
erce::remove_labels() %>%
mutate(id_k = as.numeric(as.factor(paste0(IDCNTRY)))) %>%
mutate(id_s = as.numeric(as.factor(paste0(IDCNTRY, "_", STRATA)))) %>%
mutate(id_j = as.numeric(as.factor(paste0(IDCNTRY, "_", IDSCHOOL)))) %>%
mutate(id_i = seq(1:nrow(.))) %>%
erce::lsa_weights(.,
id_i = 'id_i',
id_j = 'id_j',
id_k = 'id_k',
wt = 'WT',
wi = 'WI',
wj = 'WJ' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.