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

2011-06-06 Thread Joris Meys
On Mon, Jun 6, 2011 at 6:29 PM, peter dalgaard pda...@gmail.com wrote:

 On Jun 6, 2011, at 17:15 , Joris Meys wrote:

**snip**
 If nothing is found, an error is returned. If
 anything is found, data won't be NULL, so line 20, when reached, will
 always return FALSE. Can it be that lines 18 and 19 should be removed
 from the function?


 I think this is a false assumption. What keeps model$call$data from being 
 NULL?

Apart from a dataframe that is explicitly assigned NULL, I can't
imagine a case where model$call$data would be NULL. If it's not found,
the statement returns an error. If it is found and it is NULL, your
model call will have thrown an error earlier, so you won't even have
an object to plot. If you can give me one example where that code
actually makes sense, I'll be very happy. But right now, it doesn't
make any sense at all to me.

 No comments on the remainder, except that it wouldn't be the first time a 
 wrapper function got into trouble with environments and modelling functions...

My wrapper function returns a completely sound lm-object. Why wouldn't
I expect a function built to work on lm-objects to work on an
lm-object? At least the help files should note that the dataframe will
be sought in the calling environment, or it won't work on your fitted
objects.

Right now I have to do something like :

termplot.wrapper - function(x,...){
x$call$data - NULL
termplot(x)
}

which seems at least a tiny bit awkward...

Cheers
Joris


-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


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

2011-06-06 Thread peter dalgaard

On Jun 6, 2011, at 20:38 , Joris Meys wrote:

 On Mon, Jun 6, 2011 at 6:29 PM, peter dalgaard pda...@gmail.com wrote:
 
 On Jun 6, 2011, at 17:15 , Joris Meys wrote:
 
 **snip**
 If nothing is found, an error is returned. If
 anything is found, data won't be NULL, so line 20, when reached, will
 always return FALSE. Can it be that lines 18 and 19 should be removed
 from the function?
 
 
 I think this is a false assumption. What keeps model$call$data from being 
 NULL?
 
 Apart from a dataframe that is explicitly assigned NULL, I can't
 imagine a case where model$call$data would be NULL. If it's not found,
 the statement returns an error. If it is found and it is NULL, your
 model call will have thrown an error earlier, so you won't even have
 an object to plot. If you can give me one example where that code
 actually makes sense, I'll be very happy. But right now, it doesn't
 make any sense at all to me.

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


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


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

2011-06-06 Thread Joris Meys
On Mon, Jun 6, 2011 at 9:15 PM, peter dalgaard pda...@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?

Cheers
Joris



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


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

2011-06-06 Thread Thomas Lumley
On Tue, Jun 7, 2011 at 7:30 AM, Joris Meys jorism...@gmail.com wrote:
 On Mon, Jun 6, 2011 at 9:15 PM, peter dalgaard pda...@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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel