markmfredrickson/optmatchExperimental

. in mlm formula

Opened this issue · 1 comments

> d <- data.frame(y=rnorm(5), x=rnorm(5), z=c(0,0,1,1,1))
> d$f <- fullmatch(z ~ x, data=d)
> mlm(y ~ . - z, data=d)
Error in terms.formula(tmp, simplify = TRUE) (from mlm.R#189) :
  '.' in formula and no 'data' argument

Error arises in parseMatchingProblem's update call. Doesn't appear that update.formula supports a data argument.

Additionally, I'm not sure if as.formula(paste(".~. -", mname)) is working as expected, I believe it should be as.formula(paste(".~. -", paste(mname, collapse="-"))) if mname can ever have length > 1. Nevermind, exactly one match is enforced.

This formula munging was written before we started standardizing on using function calls (like strata(thematch)) in formulas. We might be able to significantly simplify the parsing if we force the user to specify exactly what the stratification and treatment variables are. E.g. y ~ x1 + x2 + strata(myoptmatchcolumn) or y ~ x1 + x2 + strataTreated(aFactorColumn, aLogicalColumn).