MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #1048] bug in dummy.coef.lm? #1050

Closed MichaelChirico closed 4 years ago

MichaelChirico commented 4 years ago

From: Adrian Baddeley <adrian@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> 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)))

cheers ---- Adrian Baddeley, Mathematics & Statistics, University of Western Australia http://maths.uwa.edu.au/~adrian/


METADATA

MichaelChirico commented 4 years ago

From: Prof Brian Ripley <ripley@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> On Fri, 10 Aug 2001 adrian@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> 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@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ <CENSORING FROM DETECTED PHONE NUMBER ONWARDS; SEE BUGZILLA>


METADATA

MichaelChirico commented 4 years ago

NOTES: fixed for 1.3.1: the poly(x,1) case only partially, but that is a design limit in the method used.


METADATA

MichaelChirico commented 4 years ago

Audit (from Jitterbug): Sat Aug 11 09:55:20 2001 ripley changed notes Sat Aug 11 09:55:20 2001 ripley foobar Sat Aug 11 09:55:20 2001 ripley moved from incoming to Models-fixed


METADATA