R/WAICimbal.R

#' @export
WAICimbal <-
function(alloc,xmat,carwt) {
   # evaluate covariate imbalance for each factor level of each covariate
   # returns vector of AIC(j) for each column of xmat
   
   cov_diff = apply(xmat,2,cov_diff_fcn,alloc)
   crossprod(cov_diff,carwt)/2
}

cov_diff_fcn = function(xvec,alloc) {  
   sum (tapply(alloc,xvec, function(y) {abs(mean(2*y - 1))} ) )
}

Try the SeqAlloc package in your browser

Any scripts or data that you put into this service are public.

SeqAlloc documentation built on May 2, 2019, 3:14 p.m.