Using the srvyr package and replicate weights REPWT, I would like to calculate the standard error and margin of error of the proportion (p) of households (HHWT) in the dataframe "data" that are paying over housing tax credit level rents, this is denoted in the dataframe by a "1" in the field OVERLIHTC. I'm able to get as far as shown below, but I don't know how to finish the code and print the results. Ideas?
p <- sum(data$HHWT[data$OVERLIHTC == 1]) / sum(data$HHWT)
svy <- as_survey(data, weight = HHWT , repweights = matches("REPWT[0-9]+"), type = "JK1", scale = 4/ 80 , rscales = rep(1, 80 ), mse = TRUE)
sub_design <- subset(svy, OverLIHTC == 1 )
Thanks everyone. Elizabeth, I did add the code you suggested and it produced a percent_se of .0275. I presume the is a standard error of 2.75% (not .0275%), correct? And presuming all this is on the right track, what is the code to get the margin of error (let's say for the 90% confidence interval with its factor of 1.645)?
I think David has much more statistical expertise than I do, so if he disagrees I would defer to him. I typically estimate the MOE by multiplying the SE by the critical value. I typically use 95% CI in my work and use 1.96.
Dear Elizabeth,
1.96 would be a 95% confidence interval [qnorm(0.975) ]which is typical for many statistical analyses. However the Census uses a 90% confidence interval for the MoE so the "scale" factor would be approximately 1.65
See the ACS handbook chapter 8 for the calculation
https://www.census.gov/content/dam/Census/library/publications/2020/acs/acs_general_handbook_2020_ch08.pdf
formula (2) page 60 that gives the relationship between SE (standard error) and the MoE (margin of error)
Dave