Learn R Programming

vardpoor (version 0.2.0.8.1)

vardom_othstr: Variance estimation for sample surveys in domain by the two stratification

Description

Computes the variance estimation in domain.

Usage

vardom_othstr(Y, H, H2, PSU, w_final, id=NULL,
       Dom = NULL, N_h = NULL, N_h2, s2g=FALSE,  Z = NULL,
       X = NULL, g = NULL, dataset = NULL, 
       q = rep(1, if (is.null(dataset)) nrow(data.frame(X)) else nrow(dataset)),
       confidence = .95, outp_lin=FALSE, outp_res=FALSE)

Arguments

Y
either a numeric data.frame, matrix, data.table with column names giving the variables of interest, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset' column
H
either 1 column data.frame, matrix, data.table with column name giving elements indicating the unit stratum, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset
H2
either 1 column data.frame, matrix, data.table with column name giving elements indicating the unit new stratum, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dat
PSU
either 1 column data.frame, matrix, data.table giving primary sampling unit, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset' column count) specifying the co
w_final
either a numeric vector, 1 column data.frame, matrix, data.table giving the final weights, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset' column count) sp
id
optional; either 1 column data.frame, matrix, data.table with column names giving the IDs, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset' column count)
Dom
optional; either a data.frame, matrix, data.table with column names giving different domains, or (if dataset is not NULL) character strings, integers or a logical vectors (length is the same as 'dataset' column count) sp
N_h
optional; either a matrix giving the first column - stratum, but the second column - the total of the population in each stratum.
N_h2
optional; either a matrix giving the first column - new stratum, but the second column - the total of the population in each new stratum.
s2g
by default is FALSE; calculate variance, but if s2g is TRUE, then variance estimation is taken as S^2g value.
Z
optional; either a data.frame, matrix, data.table with column names giving variables of denominator, or (if dataset is not NULL) character strings, integers or a logical vectors (length is the same as 'dataset' column co
X
optional; either a data.frame, matrix, data.table giving auxiliary variables, or (if dataset is not NULL) character strings, integers or a logical vectors (length is the same as 'dataset' column count) specifying the cor
g
optional; either a numeric vector, 1 column data.frame, matrix, data.table giving the g weights, or (if dataset is not NULL) a character string, an integer or a logical vector (length is the same as 'dataset' column cou
q
optional; either a numeric vector, 1 column data.frame, matrix, data.table giving the positive values accounting for heteroscedasticity, or (if dataset is not NULL) a character string, an integer or a logical vector (le
dataset
an optional; name of the individual dataset data.frame.
confidence
optional; either a positive value for confidence interval. This variable by default is 0.95 .
outp_lin
logical. if TRUE linearized values of the ratio estimator will be printed out
outp_res
logical. if TRUE estimated residuals of calibration will be printed out

Value

  • The function returns values:
  • estima data.table containing the estimation(s) by domain, or (if Dom is NULL) totals.
  • vara data.table containing the values of the variance estimation by domains or (if Dom is NULL) totals.
  • sea data.table containing the values of the standart error by domains or (if Dom is NULL) totals.
  • rsea data.table containing the values of the relative standart error (coefficient of variation) by domains or (if Dom is NULL) totals in percentage.
  • cva data.table containing the values of the relative standart error (coefficient of variation) by domains or (if Dom is NULL) totals.
  • absolute_margin_of_errora data.table containing the values of the absolute margin of error by domains or (if Dom is NULL) totals.
  • relative_margin_of_errora data.table containing the values of the relative margin of error by domains or (if Dom is NULL) totals.
  • CI_lowera data.table containing the values of the confidence interval lower bound by domains or (if Dom is NULL) totals.
  • CI_uppera data.table containing the values of the confidence interval upper bound by domains or (if Dom is NULL) totals.
  • var_srs_HTa matrix containing the values of the variance estimation of HT estimator under SRS by domains or (if Dom is NULL) totals.
  • var_cur_HTa matrix containing the values of the variance estimation of HT estimator under HT estimator under current design by domains or (if Dom is NULL) totals.
  • var_srs_caa matrix containing the values of the variance estimation of calibrated estimator under SRS by domains or (if Dom is NULL) totals.
  • deff_sama matrix containing the values of the estimation of the design effect of sample design by domains or (if Dom is NULL) totals.
  • deff_esta matrix containing the values of the estimation of the design effect of estimator by domains or (if Dom is NULL) totals.
  • deffa matrix containing the values of the estimation of the overall design effect of sample design and estimator by domains or (if Dom is NULL) totals.
  • lin_outa data.table containing the linearized values of the ratio estimator with id and PSU.
  • res_outa data.table containing the estimated residuals of calibration with id and PSU.
  • all_resulta data.frame containing all previosly definited values together by domains or (if Dom is NULL) totals.

Details

Calculate variance estimation on domains based on G. Osier documents.

References

Deville, J. C. (1999). Variance estimation for complex statistics and estimators: linearization and residual techniques. Survey Methodology, 25, 193-203, URL http://www5.statcan.gc.ca/bsolc/olc-cel/olc-cel?lang=eng&catno=12-001-X19990024882.

See Also

domain, lin.ratio, residual_est, vardomh, var_srs, variance_est, variance_othstr

Examples

Run this code
data(eusilc)
dataset <- data.frame(1:nrow(eusilc),eusilc)
colnames(dataset)[1] <- "IDd"
Nh <- data.table(db040=eusilc$db040, rb050=eusilc$rb050)
setkeyv(Nh, names(Nh)[1])
N_h2 <- Nh[, sum(rb050, na.rm = FALSE), keyby="db040"]

aa<-vardom_othstr("eqIncome", H="db040",H2="db040", PSU="db030", w_final="rb050",
           id="db030", Dom = "db040", N_h=NULL, N_h2, Z = NULL,
           X = NULL, g = NULL, dataset = dataset,
           q = rep(1, if (is.null(dataset)) 
                       nrow(as.data.frame(H)) else nrow(dataset)),
           confidence = .95, outp_lin=TRUE, outp_res=TRUE)

Run the code above in your browser using DataLab