Re: [Rd] variable scope in update(): bug or feature?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 22 Dec 2006 - 18:29:10 GMT

You haven't told us what you consider to be the bug here. Note that the help page for update says

      'update' will update and (by default) re-fit a model. It does this
      by extracting the call stored in the object, updating the call and
      (by default) evaluating that call. Sometimes it is useful to call
      'update' with only one argument, for example if the data frame has
      been corrected.

which seems to be exactly in accord with the behaviour you report (especially the last sentence).

Please tell us what you expected and where exactly it is documented that R works the way you expected.

On Fri, 22 Dec 2006, Michael wrote:

>
> On 22 Dec 2006, Martin Maechler wrote:
>
>> - use a simple reproducible example --
>> just for the convenience of your readers
>
> Sending email directly to r-devel doesn't seem to work for me. So I'm
> resend this via gmane.
>
> Here is an example:
>
>> rm (list = ls())
>> x <- 1:10
>> mdata <- data.frame (z = rnorm (10), y = x + 3)
>> m1 <- lm (y ~ x + z, data = mdata)
>> summary (m1)

>
> Call:
> lm(formula = y ~ x + z, data = mdata)
>
> Residuals:
> Min 1Q Median 3Q Max
> -4.950e-16 -8.107e-17 2.085e-17 9.043e-17 3.787e-16
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) 3.000e+00 1.923e-16 1.560e+16 <2e-16 ***
> x 1.000e+00 2.881e-17 3.472e+16 <2e-16 ***
> z -8.717e-17 1.149e-16 -7.590e-01 0.473
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 2.6e-16 on 7 degrees of freedom
> Multiple R-Squared: 1, Adjusted R-squared: 1
> F-statistic: 6.103e+32 on 2 and 7 DF, p-value: < 2.2e-16
>
>> x <- rep (1:2, each = 5)
>> m2 <- update (m1, ~ . - z)
>> summary (m2)

>
> Call:
> lm(formula = y ~ x, data = mdata)
>
> Residuals:
> Min 1Q Median 3Q Max
> -2.000e+00 -1.000e+00 2.086e-16 1.000e+00 2.000e+00
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) 1.000 1.581 0.632 0.54474
> x 5.000 1.000 5.000 0.00105 **
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 1.581 on 8 degrees of freedom
> Multiple R-Squared: 0.7576, Adjusted R-squared: 0.7273
> F-statistic: 25 on 1 and 8 DF, p-value: 0.001053
>
> This is R 2.4.1 on Mac OS X 10.4.8.
>
>> - use R-help. This is really a question about R.
>
> I think this could be a bug (at least it is not doing what I expected)
> so I emailed R-devel.
>
> Michael
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Dec 23 05:30:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Dec 2006 - 19:32:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.