Re: [R-pkg-devel] Determine subset from glm object

2018-07-09 Thread Heather Turner
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())

Re: [R-pkg-devel] Determine subset from glm object

2018-07-09 Thread Heather Turner
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",

Re: [R-pkg-devel] Determine subset from glm object

2018-07-09 Thread Ben Bolker
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

Re: [R-pkg-devel] Determine subset from glm object

2018-07-09 Thread Heather Turner
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

Re: [R-pkg-devel] Determine subset from glm object

2018-07-08 Thread William Dunlap
If there might be NA's in the response or predictors so na.exclude or na.omit would remove some rows as well, then using the row.names might be an easier way to match up rows in the original data with rows in gout$x. Bill Dunlap TIBCO Software wdunlap tibco.com On Sun, Jul 8, 2018 at 11:04 AM,

Re: [R-pkg-devel] Determine subset from glm object

2018-07-08 Thread Charles Geyer
I think your second option sounds better because this is all happening inside one function I'm writing so users won't be able mess with the glm object. Many thanks. On Sun, Jul 8, 2018, 12:10 PM Duncan Murdoch wrote: > On 08/07/2018 11:48 AM, Charles Geyer wrote: > > I need to find out from an

[R-pkg-devel] Determine subset from glm object

2018-07-08 Thread Charles Geyer
I need to find out from an object returned by R function glm with argument x = TRUE what the subsetting was. It appears that if gout is that object, then as.integer(rownames(gout$x)) is a subset vector equivalent to the one actually used. I do also have the call to glm (as a call object) so