Dear All,
I am trying to use simulation to test mahalanobis distance matching method.  
Somehow I do not think Matchit is giving me what I want
Below is the code:
n<-100
x1_contr<-runif(n,0,5)
x2_contr<-runif(n,0,5)
x_contr<-cbind(x1=x1_contr,x2=x2_contr)
x1_treat<-runif(n,1,6)
x2_treat<-runif(n,1,6)
x_treat<-cbind(x1=x1_treat,x2=x2_treat)
T<-c(rep(0,n),rep(1,n))
X.all<-rbind(x_contr,x_treat)

my.data<-data.frame(T,X.all)
rownames(my.data)<-paste("ID",1:dim(my.data)[1])

###MDM ###
mdm.out<-matchit(T~x1+x2,data=my.data,distance="mahalanobis",mahvars 
=c("x1","x2"), caliper=0.05,replace=FALSE)

summary(mdm.out)
Sample sizes:
          Control Treated
All           100     100
Matched       100     100
Unmatched       0       0
Discarded       0       0> match.data(m.out2)
                Y    T         x1       x2    distance weights
Y ID 1    6.2242654 0 4.04492572 2.49487149       NA       1
Y ID 2    3.7789825 0 0.08779960 3.02116199       NA       1
Y ID 3    4.5557875 0 2.18233171 1.58540582       NA       1
Y ID 4    5.4625778 0 1.49701910 4.68757127       NA       1
Y ID 5    0.2351840 0 2.64143227 0.08412851       NA       1
Y ID 6    4.5206068 0 3.57662464 1.56089398       NA       1
How can all cases and controls be matched? The data are simulated to have some 
imbalances between cases and controls. Also why distance is "NA"? I changed 
caliper values but got the same results.  Any suggestion will be appreciated.
Vincent

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to