Description Usage Arguments Value References See Also Examples
Computes the variance estimation for cross-sectional and longitudinal measures for any stage cluster sampling designs.
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 | vardcros(
Y,
H,
PSU,
w_final,
ID_level1,
ID_level2,
Dom = NULL,
Z = NULL,
gender = NULL,
country = NULL,
period,
dataset = NULL,
X = NULL,
countryX = NULL,
periodX = NULL,
X_ID_level1 = NULL,
ind_gr = NULL,
g = NULL,
q = NULL,
datasetX = NULL,
linratio = FALSE,
percentratio = 1,
use.estVar = FALSE,
ID_level1_max = TRUE,
outp_res = FALSE,
withperiod = TRUE,
netchanges = TRUE,
confidence = 0.95,
checking = TRUE
)
|
Y |
Variables of interest. Object convertible to |
H |
The unit stratum variable. One dimensional object convertible to one-column |
PSU |
Primary sampling unit variable. One dimensional object convertible to one-column |
w_final |
Weight variable. One dimensional object convertible to one-column |
ID_level1 |
Variable for level1 ID codes. One dimensional object convertible to one-column |
ID_level2 |
Optional variable for unit ID codes. One dimensional object convertible to one-column |
Dom |
Optional variables used to define population domains. If supplied, variables are calculated for each domain. An object convertible to |
Z |
Optional variables of denominator for ratio estimation. If supplied, the ratio estimation is computed. Object convertible to |
gender |
Numerical variable for gender, where 1 is for males, but 2 is for females. One dimensional object convertible to one-column |
country |
Variable for the survey countries. The values for each country are computed independently. Object convertible to |
period |
Variable for the survey periods. The values for each period are computed independently. Object convertible to |
dataset |
Optional survey data object convertible to |
X |
Optional matrix of the auxiliary variables for the calibration estimator. Object convertible to |
countryX |
Optional variable for the survey countries. The values for each country are computed independently. Object convertible to |
periodX |
Optional variable of the survey periods and countries. If supplied, residual estimation of calibration is done independently for each time period. Object convertible to |
X_ID_level1 |
Variable for level1 ID codes. One dimensional object convertible to one-column |
ind_gr |
Optional variable by which divided independently X matrix of the auxiliary variables for the calibration. One dimensional object convertible to one-column |
g |
Optional variable of the g weights. One dimensional object convertible to one-column |
q |
Variable of the positive values accounting for heteroscedasticity. One dimensional object convertible to one-column |
datasetX |
Optional survey data object in household level convertible to |
linratio |
Logical value. If value is |
percentratio |
Positive numeric value. All linearized variables are multiplied with |
use.estVar |
Logical value. If value is |
ID_level1_max |
Logical value. If value is |
outp_res |
Logical value. If |
withperiod |
Logical value. If |
netchanges |
Logical value. If value is TRUE, then produce two objects: the first object is aggregation of weighted data by period (if available), country, strata and PSU, the second object is an estimation for Y, the variance, gradient for numerator and denominator by country and period (if available). If value is FALSE, then both objects containing |
confidence |
Optional positive value for confidence interval. This variable by default is 0.95. |
checking |
Optional variable if this variable is TRUE, then function checks data preparation errors, otherwise not checked. This variable by default is TRUE. |
A list with four objects are returned by the function:
res_out
- a data.table
containing the estimated residuals of calibration with ID_level1 and PSU.
data_net_changes
- a data.table
containing aggregation of weighted data by period (if available) and countries (if available), country, strata, PSU.
var_grad
- a data.table
containing estimation for Y, the variance, gradient for numerator and denominator by period, country (if available) and population domains (if available).
results A data.table
containing:
period
- survey periods,
country
- survey countries (if available),
Dom
- optional variable of the population domains,
namesY
- names of variables of interest,
namesZ
- optional variable for names of denominator for ratio estimation,
sample_size
- the sample size (in numbers of individuals),
pop_size
- the population size (in numbers of individuals),
total
- the estimated totals,
variance
- the estimated variance of cross-sectional or longitudinal measures,
sd_w
- the estimated weighted variance of simple random sample,
sd_nw
- the estimated variance estimation of simple random sample,
pop
- the population size (in numbers of households),
sampl_siz
- the sample size (in numbers of households),
stderr_w
- the estimated weighted standard error of simple random sample,
stderr_nw
- the estimated standard error of simple random sample,
se
- the estimated standard error of cross-sectional or longitudinal,
rse
- the estimated relative standard error (coefficient of variation),
cv
- the estimated relative standard error (coefficient of variation) in percentage,
absolute_margin_of_error
- the estimated absolute margin of error,
relative_margin_of_error
- the estimated relative margin of error,
CI_lower
- the estimated confidence interval lower bound,
CI_upper
- the estimated confidence interval upper bound,
confidence_level
- the positive value for confidence interval.
Guillaume Osier, Yves Berger, Tim Goedeme, (2013), Standard error estimation for the EU-SILC indicators of poverty and social exclusion, Eurostat Methodologies and Working papers, URL http://ec.europa.eu/eurostat/documents/3888793/5855973/KS-RA-13-024-EN.PDF.
Yves G. Berger, Tim Goedeme, Guillame Osier (2013). Handbook on standard error estimation and other related sampling issues in EU-SILC, URL https://ec.europa.eu/eurostat/cros/content/handbook-standard-error-estimation-and-other-related-sampling-issues-ver-29072013_en
Eurostat Methodologies and Working papers, Handbook on precision requirements and variance estimation for ESS household surveys, 2013, URL http://ec.europa.eu/eurostat/documents/3859598/5927001/KS-RA-13-029-EN.PDF.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | library("data.table")
library("laeken")
# Example 1
data(eusilc)
set.seed(1)
dataset1 <- data.table(eusilc)
dataset1[, year := 2010]
dataset1[, country := "AT"]
dataset1[age < 0, age := 0]
PSU <- dataset1[, .N, keyby = "db030"][, N := NULL]
PSU[, PSU := trunc(runif(nrow(PSU), 0, 100))]
dataset1 <- merge(dataset1, PSU, by = "db030", all = TRUE)
PSU <- eusilc <- 0
dataset1[, strata := "XXXX"]
dataset1[, t_pov := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, t_dep := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, t_lwi := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, exp := 1]
dataset1[, exp2 := 1 * (age < 60)]
# At-risk-of-poverty (AROP)
dataset1[, pov := ifelse (t_pov == 1, 1, 0)]
# Severe material deprivation (DEP)
dataset1[, dep := ifelse (t_dep == 1, 1, 0)]
# Low work intensity (LWI)
dataset1[, lwi := ifelse (t_lwi == 1 & exp2 == 1, 1, 0)]
# At-risk-of-poverty or social exclusion (AROPE)
dataset1[, arope := ifelse (pov == 1 | dep == 1 | lwi == 1, 1, 0)]
result11 <- vardcros(Y="arope", H = "strata",
PSU = "PSU", w_final = "rb050",
ID_level1 = "db030", ID_level2 = "rb030",
Dom = "rb090", Z = NULL, country = "country",
period = "year", dataset = dataset1,
linratio = FALSE, withperiod = TRUE,
netchanges = TRUE, confidence = .95)
## Not run:
# Example 2
data(eusilc)
set.seed(1)
dataset1 <- data.table(rbind(eusilc, eusilc),
year = c(rep(2010, nrow(eusilc)),
rep(2011, nrow(eusilc))))
dataset1[, country := "AT"]
dataset1[age < 0, age := 0]
PSU <- dataset1[, .N, keyby = "db030"][, N := NULL]
PSU[, PSU := trunc(runif(nrow(PSU), 0, 100))]
dataset1 <- merge(dataset1, PSU, by = "db030", all = TRUE)
PSU <- eusilc <- 0
dataset1[, strata := "XXXX"]
dataset1[, strata := as.character(strata)]
dataset1[, t_pov := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, t_dep := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, t_lwi := trunc(runif(nrow(dataset1), 0, 2))]
dataset1[, exp := 1]
dataset1[, exp2 := 1 * (age < 60)]
# At-risk-of-poverty (AROP)
dataset1[, pov := ifelse(t_pov == 1, 1, 0)]
# Severe material deprivation (DEP)
dataset1[, dep := ifelse(t_dep == 1, 1, 0)]
# Low work intensity (LWI)
dataset1[, lwi := ifelse(t_lwi == 1 & exp2 == 1, 1, 0)]
# At-risk-of-poverty or social exclusion (AROPE)
dataset1[, arope := ifelse(pov == 1 | dep == 1 | lwi == 1, 1, 0)]
result11 <- vardcros(Y = c("pov", "dep", "arope"),
H = "strata", PSU = "PSU", w_final = "rb050",
ID_level1 = "db030", ID_level2 = "rb030",
Dom = "rb090", Z = NULL, country = "country",
period = "year", dataset = dataset1,
linratio = FALSE, withperiod = TRUE,
netchanges = TRUE, confidence = .95)
dataset2 <- dataset1[exp2 == 1]
result12 <- vardcros(Y = c("lwi"), H = "strata",
PSU = "PSU", w_final = "rb050",
ID_level1 = "db030", ID_level2 = "rb030",
Dom = "rb090", Z = NULL,
country = "country", period = "year",
dataset = dataset2, linratio = FALSE,
withperiod = TRUE, netchanges = TRUE,
confidence = .95)
### Example 3
data(eusilc)
set.seed(1)
year <- 2011
dataset1 <- data.table(rbind(eusilc, eusilc, eusilc, eusilc),
rb010 = c(rep(2008, nrow(eusilc)),
rep(2009, nrow(eusilc)),
rep(2010, nrow(eusilc)),
rep(2011, nrow(eusilc))))
dataset1[, rb020 := "AT"]
dataset1[, u := 1]
dataset1[age < 0, age := 0]
dataset1[, strata := "XXXX"]
PSU <- dataset1[, .N, keyby = "db030"][, N:=NULL]
PSU[, PSU := trunc(runif(nrow(PSU), 0, 100))]
dataset1 <- merge(dataset1, PSU, by = "db030", all = TRUE)
thres <- data.table(rb020 = as.character(rep("AT", 4)),
thres = c(11406, 11931, 12371, 12791),
rb010 = 2008:2011)
dataset1 <- merge(dataset1, thres, all.x = TRUE, by = c("rb010", "rb020"))
dataset1[is.na(u), u := 0]
dataset1 <- dataset1[u == 1]
#############
# T3 #
#############
T3 <- dataset1[rb010 == year - 3]
T3[, strata1 := strata]
T3[, PSU1 := PSU]
T3[, w1 := rb050]
T3[, inc1 := eqIncome]
T3[, rb110_1 := db030]
T3[, pov1 := inc1 <= thres]
T3 <- T3[, c("rb020", "rb030", "strata", "PSU", "inc1", "pov1"), with = FALSE]
#############
# T2 #
#############
T2 <- dataset1[rb010 == year - 2]
T2[, strata2 := strata]
T2[, PSU2 := PSU]
T2[, w2 := rb050]
T2[, inc2 := eqIncome]
T2[, rb110_2 := db030]
setnames(T2, "thres", "thres2")
T2[, pov2 := inc2 <= thres2]
T2 <- T2[, c("rb020", "rb030", "strata2", "PSU2", "inc2", "pov2"), with = FALSE]
#############
# T1 #
#############
T1 <- dataset1[rb010 == year - 1]
T1[, strata3 := strata]
T1[, PSU3 := PSU]
T1[, w3 := rb050]
T1[, inc3 := eqIncome]
T1[, rb110_3 := db030]
setnames(T1, "thres", "thres3")
T1[, pov3 := inc3 <= thres3]
T1 <- T1[, c("rb020", "rb030", "strata3", "PSU3", "inc3", "pov3"), with = FALSE]
#############
# T0 #
#############
T0 <- dataset1[rb010 == year]
T0[, PSU4 := PSU]
T0[, strata4 := strata]
T0[, w4 := rb050]
T0[, inc4 := eqIncome]
T0[, rb110_4 := db030]
setnames(T0, "thres", "thres4")
T0[, pov4 := inc4 <= thres4]
T0 <- T0[, c("rb010", "rb020", "rb030", "strata4", "PSU4", "w4", "inc4", "pov4"), with = FALSE]
apv <- merge(T3, T2, all = TRUE, by = c("rb020", "rb030"))
apv <- merge(apv, T1, all = TRUE, by = c("rb020", "rb030"))
apv <- merge(apv, T0, all = TRUE, by = c("rb020", "rb030"))
apv <- apv[(!is.na(inc1)) & (!is.na(inc2)) & (!is.na(inc3)) & (!is.na(inc4))]
apv[, ppr := ifelse(((pov4 == 1) & ((pov1 == 1 & pov2 == 1 & pov3 == 1)
| (pov1 == 1 & pov2 == 1 & pov3 == 0)
| (pov1 == 1 & pov2 == 0 & pov3 == 1)
| (pov1 == 0 & pov2 ==1 & pov3 == 1))), 1, 0)]
result20 <- vardcros(Y = "ppr", H = "strata", PSU = "PSU",
w_final = "w4", ID_level1 = "rb030",
ID_level2 = "rb030", Dom = NULL,
Z = NULL, country = "rb020",
period = "rb010", dataset = apv,
linratio = FALSE,
withperiod = TRUE,
netchanges = FALSE,
confidence = .95)
result20
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.