# NOT RUN {
#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
# }
Run the code above in your browser using DataLab