On second thoughts it may be better to preserve the original data and na.action
in the call to glm. So then you might combine the idea of a dummy model frame
with evaluating the subset, e.g.
mfcall <- call("model.frame", reformulate(all.vars(f)), data = data)
mf <- eval(mfcall, parent.frame())
Good point. In that case a solution might be to create a model frame based on
the named variables, e.g.
# general formula
f <- ~ log(x) + ns(v, df = 2)
# model frame based on "bare" variables; deal with user-supplied subset, data,
na.action, etc
mfcall <- call("model.frame",
From painful experience: model.frame() does *NOT* necessarily return a
data frame that can be successfully used as the data= argument for models.
- transformed variables (e.g. log(x)) will be in the model frame
rather than the original variables, so when model.frame() is called
again
On Sun, Jul 8, 2018, at 8:25 PM, Charles Geyer wrote:
> I spoke too soon. The problem isn't that I don't know how to get the
> subset argument. I am just calling glm (via eval) with (mostly) the
> same arguments as the call to my function, so subset is (if not
> missing) an argument to my