R/baltest.collect.R

Defines functions baltest.collect

Documented in baltest.collect

baltest.collect <-
function(matchbal.out,var.names,after=TRUE)
 {
  storemat <- matrix(NA,length(var.names),10)
  colnames(storemat) <- c("mean.Tr","mean.Co","sdiff","sdiff.pooled","var.ratio","T pval","KS pval","qqmeandiff","qqmeddiff","qqmaxdiff")
  rownames(storemat) <- var.names

  if(after==FALSE){
    stopifnot(length(matchbal.out$BeforeMatching)==length(var.names))
    for(i in 1:length(matchbal.out$BeforeMatching))
     {
      storemat[i,1] <- matchbal.out$BeforeMatching[[i]]$mean.Tr
      storemat[i,2] <- matchbal.out$BeforeMatching[[i]]$mean.Co
      storemat[i,3] <- matchbal.out$BeforeMatching[[i]]$sdiff
      storemat[i,4] <- matchbal.out$BeforeMatching[[i]]$sdiff.pooled
      storemat[i,5] <- matchbal.out$BeforeMatching[[i]]$var.ratio
      storemat[i,6] <- matchbal.out$BeforeMatching[[i]]$p.value
      TT <- try(matchbal.out$BeforeMatching[[i]]$ks$ks.boot.pvalue,silent=TRUE)
      storemat[i,7] <- ifelse(is.null(TT),NA,TT)
      storemat[i,8] <- matchbal.out$BeforeMatching[[i]]$qqsummary$meandiff
      storemat[i,9] <- matchbal.out$BeforeMatching[[i]]$qqsummary$mediandiff
      storemat[i,10] <- matchbal.out$BeforeMatching[[i]]$qqsummary$maxdiff
     }

} else {
    stopifnot(length(matchbal.out$AfterMatching)==length(var.names))
    for(i in 1:length(matchbal.out$AfterMatching))
     {
      storemat[i,1] <- matchbal.out$AfterMatching[[i]]$mean.Tr
      storemat[i,2] <- matchbal.out$AfterMatching[[i]]$mean.Co
      storemat[i,3] <- matchbal.out$AfterMatching[[i]]$sdiff
      storemat[i,4] <- matchbal.out$AfterMatching[[i]]$sdiff.pooled
      storemat[i,5] <- matchbal.out$AfterMatching[[i]]$var.ratio
      storemat[i,6] <- matchbal.out$AfterMatching[[i]]$p.value
      TT <- try(matchbal.out$AfterMatching[[i]]$ks$ks.boot.pvalue,silent=TRUE)
      storemat[i,7] <- ifelse(is.null(TT),NA,TT)
      storemat[i,8] <- matchbal.out$AfterMatching[[i]]$qqsummary$meandiff
      storemat[i,9] <- matchbal.out$AfterMatching[[i]]$qqsummary$mediandiff
      storemat[i,10] <- matchbal.out$AfterMatching[[i]]$qqsummary$maxdiff
     }
}
return(storemat)
}

Try the ebal package in your browser

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

ebal documentation built on June 9, 2022, 9:05 a.m.