File: matchit2exact.R

package info (click to toggle)
matchit 2.4-13-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,040 kB
  • ctags: 51
  • sloc: makefile: 24; csh: 13
file content (22 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
matchit2exact <- function(treat, X, data, distance, discarded, verbose=FALSE, ...){

   if(verbose)
    cat("Exact matching... \n")

  n <- length(treat)
  xx <- apply(X, 1, function(x) paste(x, collapse = "\r"))
  xx1 <- xx[treat==1]
  xx0 <- xx[treat==0]
  cc <- unique(xx1)
  cc <- cc[cc%in%xx0]
  ncc <- length(cc)
  
  psclass <- rep(NA,n)
  names(psclass) <- names(treat)
  for(i in 1:ncc)
    psclass[xx==cc[i]] <- i

  res <- list(subclass = psclass, weights = weights.subclass(psclass, treat))
  class(res) <- c("matchit.exact", "matchit")
  return(res)
}