Learn R Programming

vardpoor (version 0.8.4)

vardchanges: Variance estimation for measures of change for single and multistage stage cluster sampling designs

Description

Computes the variance estimation for measures of change for single and multistage stage cluster sampling designs.

Usage

vardchanges(Y, H, PSU, w_final, ID_level1, ID_level2, Dom = NULL, Z = NULL, country = NULL, period, dataset = NULL, period1, period2, X = NULL, countryX = NULL, periodX = NULL, X_ID_level1 = NULL, ind_gr = NULL, g = NULL, q = NULL, datasetX = NULL, annual = FALSE, linratio = FALSE, percentratio = 1, use.estVar = FALSE, outp_res = FALSE, confidence = 0.95, change_type = "absolute")

Arguments

Y
Variables of interest. Object convertible to data.table or variable names as character, column numbers.
H
The unit stratum variable. One dimensional object convertible to one-column data.table or variable name as character, column number.
PSU
Primary sampling unit variable. One dimensional object convertible to one-column data.table or variable name as character, column number.
w_final
Weight variable. One dimensional object convertible to one-column data.table or variable name as character, column number.
ID_level1
Variable for level1 ID codes. One dimensional object convertible to one-column data.table or variable name as character, column number.
ID_level2
Optional variable for unit ID codes. One dimensional object convertible to one-column data.table or variable name as character, column number.
Dom
Optional variables used to define population domains. If supplied, variables are calculated for each domain. An object convertible to data.table or variable names as character vector, column numbers.
Z
Optional variables of denominator for ratio estimation. If supplied, the ratio estimation is computed. Object convertible to data.table or variable names as character, column numbers. This variable is NULL by default.
country
Variable for the survey countries. The values for each country are computed independently. Object convertible to data.table or variable names as character, column numbers.
period
Variable for the all survey periods. The values for each period are computed independently. Object convertible to data.table or variable names as character, column numbers.
dataset
Optional survey data object convertible to data.table.
period1
The vector of periods from variable periods describes the first period.
period2
The vector of periods from variable periods describes the second period.
X
Optional matrix of the auxiliary variables for the calibration estimator. Object convertible to data.table or variable names as character, column numbers.
countryX
Optional variable for the survey countries. The values for each country are computed independently. Object convertible to data.table or variable names as character, column numbers.
periodX
Optional variable of the all survey periods. If supplied, residual estimation of calibration is done independently for each time period. Object convertible to data.table or variable names as character, column numbers.
X_ID_level1
Variable for level1 ID codes. One dimensional object convertible to one-column data.table or variable name as character, column number.
ind_gr
Optional variable by which divided independently X matrix of the auxiliary variables for the calibration. One dimensional object convertible to one-column data.table or variable name as character, column number.
g
Optional variable of the g weights. One dimensional object convertible to one-column data.table or variable name as character, column number.
q
Variable of the positive values accounting for heteroscedasticity. One dimensional object convertible to one-column data.table or variable name as character, column number.
datasetX
Optional survey data object in household level convertible to data.table.
annual
Logical value. If value is TRUE, then calculate for annual net changes.
linratio
Logical value. If value is TRUE, then the linearized variables for the ratio estimator is used for variance estimation. If value is FALSE, then the gradients is used for variance estimation.
percentratio
Positive numeric value. All linearized variables are multiplied with percentratio value, by default - 1.
use.estVar
Logical value. If value is TRUE, then R function estVar is used for the estimation of covariance matrix of the residuals. If value is FALSE, then R function estVar is not used for the estimation of covariance matrix of the residuals.
outp_res
Logical value. If TRUE estimated residuals of calibration will be printed out.
confidence
optional; either a positive value for confidence interval. This variable by default is 0.95 .
change_type
character value net changes type - absolute or relative.

Value

A list with objects are returned by the function:

References

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.

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.

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

See Also

domain, vardcros, vardchangespoor

Examples

Run this code

### Example 

data("eusilc")
set.seed(1)
eusilc1 <- eusilc[1:40,]

set.seed(1)
data <- data.table(rbind(eusilc1, eusilc1),
                   year = c(rep(2010, nrow(eusilc1)),
                            rep(2011, nrow(eusilc1))))
data[age < 0, age := 0]
PSU <- data[, .N, keyby = "db030"][, N := NULL]
PSU[, PSU := trunc(runif(nrow(PSU), 0, 5))]
data <- merge(data, PSU, all = TRUE, by = "db030")
PSU <- eusilc <- NULL
data[, strata := c("XXXX")]

data[, t_pov := trunc(runif(nrow(data), 0, 2))]
data[, exp := 1]

# At-risk-of-poverty (AROP)
data[, pov := ifelse (t_pov == 1, 1, 0)]
data[, id_lev2 := .I]

result <- vardchanges(Y = "pov", H = "strata", 
                      PSU = "PSU", w_final = "rb050",
                      ID_level1 = "db030", ID_level2 = "id_lev2",
                      Dom = NULL, Z = NULL, period = "year",
                      dataset = data, period1 = 2010,
                      period2 = 2011, change_type = "absolute")
 
## Not run: 
# data("eusilc")
# data <- data.table(rbind(eusilc, eusilc),
#                    year=c(rep(2010, nrow(eusilc)),
#                           rep(2011, nrow(eusilc))))
# data[age < 0, age := 0]
# PSU <- data[,.N, keyby = "db030"][, N := NULL]
# PSU[, PSU := trunc(runif(nrow(PSU), 0, 100))]
# data <- merge(data, PSU, all = TRUE, by = "db030")
# PSU <- eusilc <- NULL
# data[, strata := "XXXX"]
# 
# data[, t_pov := trunc(runif(nrow(data), 0, 2))]
# data[, t_dep := trunc(runif(nrow(data), 0, 2))]
# data[, t_lwi := trunc(runif(nrow(data), 0, 2))]
# data[, exp := 1]
# data[, exp2 := 1 * (age < 60)]
# 
# # At-risk-of-poverty (AROP)
# data[, pov := ifelse (t_pov == 1, 1, 0)]
#  
# # Severe material deprivation (DEP)
# data[, dep := ifelse (t_dep == 1, 1, 0)]
# 
# # Low work intensity (LWI)
# data[, lwi := ifelse (t_lwi == 1 & exp2 == 1, 1, 0)]
# 
# # At-risk-of-poverty or social exclusion (AROPE)
# data[, arope := ifelse (pov == 1 | dep == 1 | lwi == 1, 1, 0)]
# data[, dom := 1]
# data[, id_lev2 := .I]
# 
# result <- vardchanges(Y = c("pov", "dep", "lwi", "arope"),
#                       H = "strata", PSU = "PSU", w_final = "rb050",
#                       ID_level1 = "db030", ID_level2 = "id_lev2",
#                       Dom = "rb090", Z = NULL, period = "year",
#                       dataset = data, period1 = 2010, 
#                       period2 = 2011, change_type = "absolute")
# ## End(Not run)

Run the code above in your browser using DataLab