This data set contains some variables from the 2001 Survey of Household Spending (SHS) carried out by Statistics Canada. The main purpose of this survey is to obtain detailed information about household spending during the reference year.
A data frame with 16057 observations on the following 7 variables.
Weight at household level
Province or territory code
Urban rural code
Size of area of residence code
Household income before taxes
Household spending on recreation
In this package,
HHINCTOT is used as a stratification variable and
M101 as a survey variable.
Income Statistics Division, Statistics Canada.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
# Estimation of the response rate X <- SHS$HHINCTOT[SHS$HHINCTOT>0] Y <- SHS$M101[SHS$HHINCTOT>0] Y[Y<0] <- 0 p<-sum(Y>0)/length(Y) # Study of the relationship between X and Y for the active units Xactive <- SHS$HHINCTOT[SHS$HHINCTOT>0&SHS$M101>0] Yactive <- SHS$M101[SHS$HHINCTOT>0&SHS$M101>0] plot(log(Xactive), log(Yactive)) # Extreme values are omitted for a more robust estimation keep <- Xactive/Yactive>quantile(Xactive/Yactive,0.01)& Xactive/Yactive<quantile(Xactive/Yactive,0.99) plot(log(Xactive)[keep], log(Yactive)[keep]) reg <- lm( log(Yactive)[keep]~log(Xactive)[keep] ) summary(reg) # Stratification assuming X=Y nomodel <- strata.LH(x=X, CV=0.05, Ls=3, alloc=c(0.5,0,0.5), takeall=0, model="none", algo.control=list(trymany=FALSE, rep=2)) nomodel var.strata(nomodel, y=Y) # The target CV is far from being reached # Stratification taking into account a loglinear model with mortality # between X and Y, using the estimated parameters values model <- strata.LH(x=X, CV=0.05, Ls=3, alloc=c(0.5,0,0.5), takeall=0, model="loglinear", model.control=list(beta=reg$coef, sig2=summary(reg)$sigma^2, ph=0.97), initbh=nomodel$bh, algo.control=list(trymany=FALSE, rep=2)) model var.strata(model,y=Y) # The target CV is reached
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.