Description Usage Arguments Details Value Source References Examples
sandwich
calculates the covariance structure between timepoints given matrices yCov
, D
,V
and correctionmatrix
. This is done to be able to account for missingness in the Data.
1 2 3 4 5 6 7 8 |
yCov |
yCov matrix containing either an estimation for the covariance between timepoints or an empirical covariance matrix itsel. see 'Details'. |
D |
D denotes the mean matrix of all entries of Δμ_i/δβ, where this is the average over all |
V |
V denotes the working covariance matrix. see 'Details'. |
correctionmatrix |
As of this version this matrix is needed to correct some calculations. see 'Details' to see for more details and how to correctly select matrices. |
missing |
vector which denotes the probability to experience a dropout at each timepoint. If |
missingtype |
String which describes the type of missingness occuring in the data. |
yCov
is either empirical or the estimated covariance-matrix between timepoints which is needed to calculate the sandwich estimator. This matrix can either be generated by estimating the empirical covariance matrix using existing data or by using function gen_cov_cor
to calculate a estimation for the covariance.
D
denotes the estimation of n^-1* ∑_i^N Δμ_i/δβ, which means that D=E(D_i). As of yet this has the unfortunate side effect that E(D_i
sandwich
returns the robust covariance estimator of regression coefficients which are implicitly defined by D
.
sandwich
computes the asymptotic sandwich covariance estimator and uses code contributed by Roland Gerard Gera.
Liang Kung-Yee, Zeger Scott L. (1986); Jung Sin-Ho, Ahn Chul (2003); Wachtlin Daniel Kieser Meinhard (2013)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #Let's assume we wish to calculate the robust variance estimator for equation
#\eqn{y_{it}=\beta_0+\beta_1*I_{treat}+\beta_2*t+\beta_3*I _{treat}*t+\epsilon_{it}}.
#Furthermore we use the identitiy matrix as the working covariance matrix.
#The chance to get treatment is 60 percent and the observed timerange ranges from 0:5.
ycov = gen_cov_cor(var = 3,rho = 0.25,theta = 1,Time = 0:5,cov = TRUE)
D = matrix(c(1,0.6,0,0,
1,0.6,1,0.6,
1,0.6,2,1.2,
1,0.6,3,1.8,
1,0.6,4,2.4,
1,0.6,5,3.0),nrow=4)
D=t(D)
V=diag(1,length(0:5))
#We correct entries where E(D_i %*% D_i) is unequal to E(D_i)%*%E(D_i) (D %*% D).
correctionmatrix=matrix(c(1,1,1,1,1,1/0.6,1,1/0.6,1,1,1,1,1,1/0.6,1,1/0.6),nrow=4)
missingtype = "none"
robust=sandwich(yCov=ycov,D=D,V=V,missingtype=missingtype,correctionmatrix=correctionmatrix)
robust
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.