View source: R/regest_strata.r
regest_strata | R Documentation |
Computes the regression estimator of the population total for a stratified sampling, using the design-based approach. The same regression model is used for all strata. The underling regression model is a model without intercept.
regest_strata(formula,weights,Tx_strata,strata,pikl,
sigma=rep(1,length(weights)),description=FALSE)
formula |
regression model formula (y~x). |
weights |
vector of the weights; its length is equal to n, the sample size. |
Tx_strata |
population total of x, the auxiliary variable. |
strata |
vector of stratum identificator. |
pikl |
joint inclusion probabilities for the sample. |
sigma |
vector of positive values accounting for heteroscedasticity. |
description |
if TRUE, the following components are printed for each stratum: the Horvitz-Thompson estimator, the estimated beta coefficients, their estimated standard error, t_values, p_values, and the covariance matrix. By default, FALSE. |
The function returns the value of the regression estimator computed as the sum of the stratum estimators.
regest
# generates artificial data
y=rgamma(10,3)
x=y+rnorm(10)
Stratum=c(1,1,2,2,2,3,3,3,3,3)
# population size
N=200
# sample size
n=10
# assume proportional allocation, nh/Nh=n/N
# joint inclusion probabilities (for the sample)
pikl=matrix(n*(n-1)/(N*(N-1)),n,n)
diag(pikl)=n/N
regest_strata(formula=y~x-1,weights=rep(N/n,n),Tx_strata=c(50,30,40),
strata=Stratum,pikl,description=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.