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"
library(srvyr)
library(dplyr)
library(survey)
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")