From 469a88122da827b6987c384c48b22a3d3a2b18ff Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 17 Dec 2024 23:25:05 +0100 Subject: [PATCH] fix --- R/rescale_weights.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/rescale_weights.R b/R/rescale_weights.R index d18bdac0e..8f73b948a 100644 --- a/R/rescale_weights.R +++ b/R/rescale_weights.R @@ -131,7 +131,7 @@ rescale_weights <- function(data, by, probability_weights, nest = FALSE, method # design effect according to Kish deff <- mean(weights^2) / (mean(weights)^2) # rescale weights, so their mean is 1 - z_weights <- ((weights + 1) - mean(weights) ) / stats::sd(weights) + z_weights <- weights * (1 / mean(weights)) # divide weights by design effect data$pweight <- NA_real_ data$pweight[weight_non_na] <- z_weights / deff