Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 17, 2024
1 parent 469a881 commit c08b07a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/rescale_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c08b07a

Please sign in to comment.