I had a typo in the prior example when transcribing from R to the message, now corrected below. (The call to myfun).
  My apologies for that.  Corrected message below.

Someone has reported a problem with predict.coxph that I can't seem to solve.  
The
underlying issue is with model.frame.coxph; the same issue is also found in lm 
so I'll use
that for the example.

--------------------------

test <- data.frame(y = 1:10 + runif(10), x=1:10)

myfun <- function(formula, nd) {
    fit <- lm(formula, data=nd, model=FALSE)
    model.frame(fit)
    }

myfun( y~x, test)
Error in is.data.frame(data): object "nd" not found

--------------------

1. The key line, in both model.frame.coxph and model.frame.lm is
    eval(fcall, env, parent.frame())

and it appear (at least to me) that the parent.frame() part of this is 
effectively ignored
when fcall is itself a reference to model.frame.  I'd like to understand this 
better.


2. The modeling functions coxph and survreg in the survival default to 
model=FALSE,
originally in mimicry of lm and glm; I don't know when R changed the default to 
model=TRUE
for lm and glm.  One possible response to my question would be advice to change 
my
routine's defaults too.  I'm somewhat reluctant since I work with a few very 
large data
sets, but would entertain that discussion as well.   I'd still like to 
understand how
model.frame could be made to work under the current regimen.

Terry Therneau

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to