Re: [R] scoping problem

2007-10-24 Thread Prof Brian Ripley
Local updating is what I would have recommended. But predict() will work correctly with NA values in the fit if the latter was done with na.action=na.exclude. I would find it clearer to use fitted() here, which also works for na.action=na.exclude. On Wed, 24 Oct 2007, Christos Hatzis wrote: >

Re: [R] scoping problem

2007-10-24 Thread Gabor Grothendieck
See: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67474.html and also the other posts in that thread. On 10/24/07, Sandy Weisberg <[EMAIL PROTECTED]> wrote: > I would like to write a function that computes Tukey's 1 df for > nonadditivity. Here is a simplified version of the function I'd lik

Re: [R] scoping problem

2007-10-24 Thread Christos Hatzis
Another way to do this without messing with environments is to update the data and formula locally within the function and re-run the regression on the updated model/data: tukey.test <- function(m) { ud <- data.frame( m$model, pred2=m$fitted.values^2 ) uf <- update.formula(formula(m$terms)

Re: [R] scoping problem

2007-10-24 Thread Duncan Murdoch
On 10/24/2007 3:43 PM, Sandy Weisberg wrote: > I would like to write a function that computes Tukey's 1 df for > nonadditivity. Here is a simplified version of the function I'd like to > write: (m is an object created by lm): > > tukey.test <- function(m) { > m1 <- update(m, ~.+I(predict(m)^