From c08b07a1afd48004b0e28e5eaac69b50b6d9c5d6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 17 Dec 2024 23:26:13 +0100 Subject: [PATCH] lintr --- R/rescale_weights.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/rescale_weights.R b/R/rescale_weights.R index 8f73b948a..162863609 100644 --- a/R/rescale_weights.R +++ b/R/rescale_weights.R @@ -127,11 +127,11 @@ rescale_weights <- function(data, by, probability_weights, nest = FALSE, method # rescale weights, method Carle ---------------------------- .rescale_weights_kish <- function(probability_weights, data_tmp, data, weight_non_na) { - weights <- data_tmp[[probability_weights]] + p_weights <- data_tmp[[probability_weights]] # design effect according to Kish - deff <- mean(weights^2) / (mean(weights)^2) + deff <- mean(p_weights^2) / (mean(p_weights)^2) # rescale weights, so their mean is 1 - z_weights <- weights * (1 / mean(weights)) + z_weights <- p_weights * (1 / mean(p_weights)) # divide weights by design effect data$pweight <- NA_real_ data$pweight[weight_non_na] <- z_weights / deff