Re: [Rd] Possible bug in termplot function (stats package) ?

From: Thomas Lumley <tlumley_at_uw.edu>
Date: Tue, 07 Jun 2011 08:16:21 +1200

On Tue, Jun 7, 2011 at 7:30 AM, Joris Meys <jorismeys_at_gmail.com> wrote:
> On Mon, Jun 6, 2011 at 9:15 PM, peter dalgaard <pdalgd@gmail.com> wrote:

>>
>> I'd say that the burden of proof is really on your side, but how hard can it be:
>>
>>> x <- 1:10
>>> y <- rnorm(10)
>>> m <- lm(y~x)
>>> m$call
>> lm(formula = y ~ x)
>>> m$call$data
>> NULL
>>

> I see... indeed, thx for the answer and sorry for my stupidity. Should
> have thought about that case. Still, I wonder why it is necessary to
> go look for the data in a calling environment if it should be
> contained in the model frame of the fitted object. Or am I again wrong
> in assuming that's always the case?

You are again wrong. Life would be much simpler if the data were always available like that, but there are at least two problems.

  1. There need not be a model frame in the fitted object. (it's optional)
  2. More importantly, if you have y~sin(x), the model frame will contain sin(x), not x. For what termplot() does, it has to be able to reconstruct 'x', which isn't possible without the original data.

It's quite possible that termplot() could be rewritten to be simpler and more general, but I don't think minor editing will do it.

    -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon 06 Jun 2011 - 20:21:05 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 06 Jun 2011 - 21:50:16 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.

list of date sections of archive