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
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 forZI think it would be easier for users if it also allowed data frames, like you could include a line like
or something.
Even better would be if you could have an optional
dataargument toloop, and then allowed formulas. Then you could call it like:or even just
where
posttest,condition,x1-x3are columns ofdat