From ripley@stats.ox.ac.uk  Fri Aug 10 12:56:02 2001
From: ripley@stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 10 Aug 2001 12:56:02 +0100 (BST)
Subject: [Rd] bug in dummy.coef.lm? (PR#1048)
In-Reply-To: <200108100824.KAA24354@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.31.0108101251250.31406-100000@gannet.stats>

On Fri, 10 Aug 2001 adrian@maths.uwa.edu.au wrote:

> Hi -
> I'm running R 1.3.0 on i686-pc-linux-gnu
>
> 	> rm(x, y, z)
> 	> df <- data.frame(x=1:20,y=1:20,z=factor(1:20 <= 10))
>
> dummy.coef falls over:
>
> 	> dummy.coef.lm(lm(y ~ z * poly(x,1), data=df))
> 	Error in poly(x, 1): Object "x" not found
> 	> dummy.coef.lm(lm(y ~ z * I(x), data=df))
> 	Error in unique(c("AsIs", class(x))): Object "x" not found
>
> but works OK with:
> 	> dummy.coef.lm(lm(y ~ z * x, data=df))
> 	> dummy.coef.lm(lm(y ~ poly(x,1), data=df))
> 	> dummy.coef.lm(lm(y ~ I(x), data=df))
>
> 	> x <- df$x
> 	> y <- df$y
> 	> z <- df$z
> 	> dummy.coef.lm(lm(y ~ z * poly(x,1)))
> 	> dummy.coef.lm(lm(y ~ z * I(x)))

Not for me it doesn't ...

This is a known design problem: it's been like it for three years.
I think I know how to solve it ....

Note: ?dummy.coef says

     There will be
     little point in using `dummy.coef' for `contr.treatment'
     contrasts, as the missing coefficients are by definition zero.

and what are the default contrasts in R?

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] bug in dummy.coef.lm? (PR#1048)
Prof Brian Ripley