I want to test for differences of the known proportion of the population vs. the proportion of a sample. The sample is weighted by sampling weights. The sum of weights is equal to the size of the population.
Consider the following example (coded in
set.seed(12345) theta <- 0.7 # True population value N <- 100000 # Sample size samp_values <- rbinom(N, 1, 0.69) # Sample values weights <- runif(N, 0, 20) # Sampling weights (summing up to the population size)
theta_hat <- sum((samp_values * weights)) / sum(weights) # Weighted proportion (theta_hat - theta) / sqrt((theta * (1 - theta)) / N) # z-test #  -7.101598
To me the result seems to be fine. However, the other thread is not taking weights into account and surprisingly I did not find any other sources about the topic.
Question: How could weights be incorporated into a test for differences between population proportion and weighted sample proportion?