Hello,
I am using boot() to compute standard errors for a matching estimator.
I ran into a problem while writing the statistic function required by
boot. I kept getting the following error:
> boot(p,statistic=est.sub,R=1)->boot.s
Error in eval(expr, envir, enclos) : object "d1" not found
After mucking around, it seems to have been a problem with the way
matchit() creates and object (that I was then plugging into
match.data()). The function est.sub is below, note the line with
comment. When that line is commented out, I get the above error. If
not, things work fine.
est.sub<-function(d,b) {
d[b,]->d1
f<-formula(coach~psatm+psatv+age+ses+female+asian+black+hispanic+native+priv+rur+urb+ap+rem_eng+rem_math+prep+byread+bymath+mcrd+hw+esl+after+info+prep_par+edu_par)
subclass.estimates<-matrix(nrow=5,ncol=2)
matchit(f,d1,method="subclass",distance="logit",subclass=5,sub.by="treat",discard="both")->foo
####d1->foo$call$data ###wtf is going on with this line!!!!!
match.data(foo)->d2
est<-numeric(length=2)
for (j in 1:5) {
c<-d2[d2$subclass==j & d2$coach==1,]
n<-d2[d2$subclass==j & d2$coach==0,]
mean(c$satm)-mean(n$satm)->subclass.estimates[j,1]
mean(c$satv)-mean(n$satv)->subclass.estimates[j,2]
}
mean(subclass.estimates[,1])->est[1]
mean(subclass.estimates[,2])->est[2]
return(est)
}
Any thoughts? I feel like I've gotten things working, at least for my
purposes, but I'm not sure if this is pointing at a larger problem or
if I've done something odd.
Ben
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/