library(dplyr)
# Load example data
data(data_s);data(univ)
summary(univ)
# \donttest{
formula<-as.formula(occ_stat~(1|pro)+factor(sexage)+factor(edu)+factor(fore))
# Drop from the universe data frame variables not referenced in the formula or in the broadarea
univ_1<-univ[,-5]
# 1) Estimation using the complete list of the unit beloging the target population:
example.1<-mind.unit(formula=formula,dom="dom",data=data_s,universe=univ_1)
rm(univ_1)
# Creation of the know population totals object:
univ_ag<-aggregate(tot~-1+factor(dom)+factor(pro)+
factor(sexage)+factor(edu)+factor(fore),univ,sum)
colnames(univ_ag)<-c("dom","pro","sexage","edu","fore","tot")
# Set all variables as numeric.
#Remember that only the domains codes and the random terms must to be numeric variables.
univ_ag <- mutate_all(univ_ag, function(x) as.numeric(as.character(x)))
# 2) Estimation using the know population totals (totals in univ_ag) :
example.2<-mind.unit(formula=formula,dom="dom",data=data_s,universe=univ_ag)
# }
Run the code above in your browser using DataLab