From therneau at mayo.edu  Wed May 16 22:59:56 2012
From: therneau at mayo.edu (Terry Therneau)
Date: Wed, 16 May 2012 15:59:56 -0500
Subject: [Rd] Evaluation without using the parent frame
Message-ID: <4FB4154C.1070406@mayo.edu>

I've been tracking down a survival problem from R-help today.  A short 
version of the primary issue is reconstructed by the following simple 
example:

library(survival)
attach(lung)
fit <- coxph(Surv(time, status) ~ log(age))
predict(fit, newdata=data.frame(abe=45))

Note the typo in the last line of "abe" instead of "age".  Instead of an 
error message, this returns predictions for all the subjects since 
model.frame matches "age" by searching more widely.   I'd prefer the error.
I suspect this is hard -- I'd like it to not see the attached lung data 
set, but still be able to find the log function.
Is there a not-horribly-complex solution?

I also tried to change the primary function to lm instead of coxph.  It 
has the same problem, but does print a warning that the newdata and 
results have different lengths (which I will incorporate).

Terry T.



[Rd] Evaluation without using the parent frame
Terry Therneau