Learn R Programming

vardpoor (version 0.17.0)

vardbootstr: Variance estimation for measures of annual net change or annual for single stratified sampling designs

Description

Computes the variance estimation for measures of annual net change or annual for single stratified sampling designs.

Usage

vardbootstr(boots_count = 500, Y, H, PSU,
            w_final, ID_level1, Z = NULL,
            Dom = NULL, dh = 1, fpc, dataset = NULL,
            years, subperiods = NULL, year1 = NULL,
            year2 = NULL, percentratio = 100,
            confidence = 0.95, method = "cros")

Arguments

boots_count

Positive numeric value. Number of replicates, by default - 100

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 unit ID codes. One dimensional object convertible to one-column data.table or variable name as character, column number.

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.

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.

dh

n_h-m_h, where n_h is the stratum size and m_h the number of units sampled with replacement. By default, dh=1 (HFCN recommendation)

fpc

Variable for the finite population correction (sampling rate = n_h/N_h). Default = 0.

dataset

Optional survey data object convertible to data.table.

years

Variable for the all survey years. The values for each year are computed independently. Object convertible to data.table or variable names as character, column numbers.

subperiods

Variable for the all survey subperiods. The values for each subperiod are computed independently. Object convertible to data.table or variable names as character, column numbers.

year1

The vector of years from variable years describes the first year for measures of annual net change.

year2

The vector of years from variable periods describes the second year for measures of annual net change.

percentratio

Positive numeric value. All linearized variables are multiplied with percentratio value, by default - 1.

confidence

optional; either a positive value for confidence interval. This variable by default is 0.95.

method

character value; value 'cros' is for measures of annual or value 'netchanges' is for measures of annual net change. This variable by default is netchanges.

Value

A list with objects are returned by the function:

crossectional_results

A data.table containing: year - survey years, subperiods - survey subperiods, variable - names of variables of interest, Dom - optional variable of the population domains, estim - the estimated value, var - the estimated variance of cross-sectional and longitudinal measures, sd_w - the estimated weighted variance 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.

annual_results

A data.table containing year_1 - survey years of years1 for measures of annual net change, year_2 - survey years of years2 for measures of annual net change, Dom - optional variable of the population domains, variable - names of variables of interest, estim_2 - the estimated value for period2 for measures of annual net change, estim_1 - the estimated value for period1 for measures of annual net change, estim - the estimated value, var - the estimated variance, se - the estimated standard error, 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 for period1 for measures of annual, relative_margin_of_error - the estimated relative margin of error in percentage for measures of annual, CI_lower - the estimated confidence interval lower bound, CI_upper - the estimated confidence interval upper bound, confidence_level - the positive value for confidence interval, significant - is the the difference significant

References

Guillaume OSIER, Virginie RAYMOND, (2015), Development of methodology for the estimate of variance of annual net changes for LFS-based indicators. Deliverable 1 - Short document with derivation of the methodology.

See Also

vardchanges, vardannual

Examples

Run this code
# NOT RUN {
### Example 
data("eusilc")
set.seed(1)
eusilc1 <- eusilc[1 : 20,]
set.seed(1)
require(data.table)
data <- data.table(rbind(eusilc1, eusilc1),
                   year = c(rep(2010, nrow(eusilc1)),
                            rep(2011, nrow(eusilc1))))
data[, half:= .I - 2 * trunc((.I - 1) / 2)]
data[, quarter:= .I - 4 * trunc((.I - 1) / 4)]
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[, employed := trunc(runif(nrow(data), 0, 2))]
data[, id_lv2 := paste0("V", .I)]
data[, fpc := 0]

# }
# NOT RUN {
result <- vardbootstr(boots_count = 500, = "employed", H = "strata",
                      PSU = "PSU", w_final = "rb050", ID_level1 = "ids",
                      Z = NULL, Dom = NULL, dh = 1, fpc = "fpc",
                      dataset = data, years = "year",
                      subperiods = "half", year1 = 2010,
                      year = 2011, percentratio = 100,
                      confidence = 0.95, method = "netchanges") 
# }

Run the code above in your browser using DataLab