variance_othstr: Variance estimation for sample surveys by the new...

Description Usage Arguments Details Value References See Also Examples

View source: R/variance_othstr.R

Description

Computes s2g and the variance estimation by the new stratification.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
variance_othstr(
  Y,
  H,
  H2,
  w_final,
  N_h = NULL,
  N_h2,
  period = NULL,
  dataset = NULL,
  checking = TRUE
)

Arguments

Y

Variables of interest. Object convertible to data.table or variable names as character, column numbers or logical vector with only one TRUE value (length of the vector has to be the same as the column count of dataset).

H

The unit stratum variable. One dimensional object convertible to one-column data.table or variable name as character, column number or logical vector with only one TRUE value (length of the vector has to be the same as the column count of dataset).

H2

The unit new stratum variable. One dimensional object convertible to one-column data.table or variable name as character, column number or logical vector with only one TRUE value (length of the vector has to be the same as the column count of dataset).

w_final

Weight variable. One dimensional object convertible to one-column data.table or variable name as character, column number or logical vector with only one TRUE value (length of the vector has to be the same as the column count of dataset).

N_h

optional; either a data.frame giving the first column - stratum, but the second column - the total of the population in each stratum.

N_h2

optional; either a data.frame giving the first column - new stratum, but the second column - the total of the population in each new stratum.

period

Optional variable for the survey periods. If supplied, the values for each period are computed independently. One dimensional object convertible to one-column data.table or variable name as character, column number or logical vector with only one TRUE value (length of the vector has to be the same as the column count of dataset).

dataset

Optional survey data object convertible to data.table.

checking

Optional variable if this variable is TRUE, then function checks data preparation errors, otherwise not checked. This variable by default is TRUE.

Details

It is possible to compute population size M_g from sampling frame. The standard deviation of g-th stratum is

S_g^2 =1/(M_g-1) ∑ k=1...M_g (y_gk - Ym_g)^2= 1/(M_g-1) ∑ k=1...M_g (y_gk)^2 - M_g/(M_g-1)*(Ym_g)^2

∑ k=1...M_g (y_gk)^2 and Ym_g^2 have to be estimated to estimate S_g^2. Estimate of ∑ k=1...M_g (y_gk)^2 is ∑ h=1...H N_h/n_h ∑ i=1...n_h (y_gi)^2*z_hi, where

z_hi=if(0, h_i notin θ_g; 1, h_i in θ_g) , θ_g is the index group of successfully surveyed units belonging to g-th stratum. #'Estimate of (Y_g)^2 is

Ym_g^2=(Ym_g)^2- Var(Ym)

Ym_g =Ym_g/M_g= 1/M_g ∑ h=1...H N_h/n_h ∑ i=1...n_h y_hi z_hi

So the estimate of S_g^2 is

s_g^2=\1/(M_g-1) ∑ h=1...H N_h/n_h ∑ i=1...n_h (y_hi)^2 * z_hi -

-M_g/(M_g-1) (1/M_g ∑ h=1...H N_h/n_h ∑ i=1...n_h y_hi z_hi)^2

Two conditions have to realize to estimate S_g^2: n_h>1, forall g and θ_g <> 0, forall g.

Variance of Y is

Var(Y) = ∑ g=1...G M_g^2 (1/m_g - 1/M_g)*(S_g)^2

Estimate of Var(Y) is

Var(Y)= ∑ g=1...G M_g^2 (1/m_g - 1/M_g)*(s_g)^2

Value

A list with objects are returned by the function:

References

M. Liberts. (2004) Non-response Analysis and Bias Estimation in a Survey on Transportation of Goods by Road.

See Also

domain, lin.ratio, linarpr, linarpt, lingini, lingini2, lingpg, linpoormed, linqsr, linrmpg, residual_est, vardom, vardom_othstr, vardomh, varpoord

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library("data.table")
Y <- data.table(matrix(runif(50) * 5, ncol = 5))
   
H <- data.table(H = as.integer(trunc(5 * runif(10))))
H2 <- data.table(H2 = as.integer(trunc(3 * runif(10))))
   
N_h <- data.table(matrix(0 : 4, 5, 1))
setnames(N_h, names(N_h), "H")
N_h[, sk:= 10]
   
N_h2 <- data.table(matrix(0 : 2, 3, 1))
setnames(N_h2, names(N_h2), "H2")
N_h2[, sk2:= 4]
   
w_final <- rep(2, 10)
   
vo <- variance_othstr(Y = Y, H = H, H2 = H2,
                      w_final = w_final,
                      N_h = N_h, N_h2 = N_h2,
                      period = NULL,
                      dataset = NULL)
vo

vardpoor documentation built on Nov. 30, 2020, 5:08 p.m.