manncz / dRCT

Design-based analysis of RCTs
1 stars 0 forks source link

More flexible specification for Z matrix #4

Open adamSales opened 1 year ago

adamSales commented 1 year ago

I'm trying to help a colleague use loop and it occurred to me that it would be easier if we required less data pre-processing from the user. (Ideally it would be no harder than calling lm() in my opinion). So here's something:

Right now (I think), loop() only takes a matrix or a vector for Z I think it would be easier for users if it also allowed data frames, like you could include a line like

if(is.data.frame(Z)) Z <- model.matrix(~.,data=Z)[,-1]

or something.

Even better would be if you could have an optional data argument to loop, and then allowed formulas. Then you could call it like:

loop(Y~Tr, covariates= ~x1+x2+x3, data=dat)

or even just

loop(Y=posttest,Tr=condition, Z=c(x1,x2,x3),data=dat)

where posttest, condition, x1-x3 are columns of dat