Using replicate weights to get error margins

I'm trying to get error margins using replicate weights with Census 5-year ACS PUMS data. In the code below I get the error message in step #4, ideas?:

survey_margin_of_error(survey_total(HHWT)). Caused by error in survey_margin_of_error()`: ! could not find function "survey_margin_of_error"


1 Load the data

data <-read.csv("D:/mhp3/usa_00026.csv")

2 Divide the total number of households by 5

total_households <-sum(data$HHWT)/5

3 Define the survey design

design <-data %>% as_survey_design(weights ="HHWT", repweights ="REPWT", scale =80)

4 Calculate the MOE

moe <-design %>% summarise(moe =survey_margin_of_error(survey_total(HHWT)))

5 Print the MOE to the console

cat("The Margin of Error for a total of households is", round(moe$moe,2),"with a 95% confidence interval.\n")

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.