Learn R Programming

vardpoor (version 0.17.0)

vardchangstrs: Variance estimation for measures of change for stratified simple random sampling

Description

Computes the variance estimation for measures of change for stratified simple random sampling.

Usage

vardchangstrs(Y, H, PSU, w_final,
              Dom = NULL, periods = NULL,
              dataset, periods1, periods2,
              in_sample, in_frame,
              confidence = 0.95,
              percentratio = 1)

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.

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.

periods

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.

periods1

The vector of periods from variable periods describes the first period for measures of change.

periods2

The vector of periods from variable periods describes the second period for measures of change.

in_sample

Sample variable. One dimensional object convertible to one-column data.table or variable name as character, column number.

in_frame

Frame variable. One dimensional object convertible to one-column data.table or variable name as character, column number.

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.

Value

A list with objects are returned by the function:

annual_sum

A data.table containing year - survey years, country - survey countries, Dom - optional variable of the population domains, namesY - variable with names of variables of interest, namesZ - optional variable with names of denominator for ratio estimation, totalY - the estimated value of variables of interest for period1, totalZ - optional the estimated value of denominator for period2, year - survey years of years for measures of annual, year_1 - survey years of years1 for measures of annual net change, year_2 - survey years of years2 for measures of annual net change, country - survey countries, Dom - optional variable of the population domains, namesY - variable with names of variables of interest, namesZ - optional variable with names of denominator for ratio estimation, estim_1 - the estimated value for period1 for measures of annual net change, estim_2 - the estimated value for period2 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

Nordberg, L. ((2000), On Variance Estimation for Measures of Change When Samples are Coordinated by the Use of Permanent Random Numbers. Journal of Official Statistics 16, 363?378

See Also

domain

Examples

Run this code
# NOT RUN {
### Example 
data("eusilc")
set.seed(1)
eusilc1 <- eusilc[1 : 100,]
set.seed(1)
require(data.table)
datas <- data.table(rbind(eusilc1, eusilc1),
                     year = c(rep(2010, nrow(eusilc1)),
                              rep(2011, nrow(eusilc1))))

PSU <- datas[, .N, keyby = "db030"][, N:= NULL]
PSU[, PSU:= trunc(runif(nrow(PSU), 0, 5))]
datas <- merge(datas, PSU, all = TRUE, by = "db030")
datas[, strata := c("XXXX")]

datas[, calc := trunc(runif(nrow(datas), 0, 2))]
datas[, id_lv2 := paste0("V", .I)]

# }
# NOT RUN {
result <- vardchangstrs(Y = "calc", H = "strata",
                        PSU = "PSU", w_final = "rb050",
                        ID_level1 = "db030", ID_level1 = "id_lv2",
                        periods = "year", dataset = datas,
                        periods1 = 2010, periods2 = 2011,
                        percentratio = 100, confidence = 0.95) 
# }

Run the code above in your browser using DataLab