| univ | R Documentation |
Synthetic population data frame containing the complete list of the units belonging to the target population along with the corresponding values of the auxiliary variables.
data(univ)
A data frame with 514320 observations on 7 variables:
domdomain of interest codes
sexagecross classification of age and sex
edueducational level
forebynary variable, 2 for foreigner 1 otherwise
munmunicipal codes
proprovincial codes
totcolumn of 1
The informations on the population are the same collected in the syntethic sample data_s appart from the information on the occupational status that are present only for the sample units.
mind.unit allows to use a data frame of known population totals based on the marginal distribution of the profile identified by the auxiliary variables (See 'Examples').
library(dplyr)
# Load example data
data(data_s);data(univ)
summary(univ)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.