[R] Dummies multiplied with other variable (solved)

Andreas Goesele Goesele at hfph.mwn.de
Fri Dec 1 13:18:49 CET 2006


"David Barron" <mothsailor at googlemail.com> writes:

> I'm not sure if this will help, but it's worth a try.  Do the
> regression as I suggested before, extract the model matrix and remove
> the "offending" column.  I'm assuming you don't know in advance how
> many levels there are in the factor.  Then use this to perform the
> regression.  Something like this:
>
> m1 <- lm(x ~ fd:y + fd)
> mm <- model.matrix(m1)
> nl <- length(levels(fd))
> newdat <- mm[,-c(1,nl)]
> lm(x ~ newdat)

Thanks a lot! With a small change that solved my problem!

-- 
Andreas Gösele                   Omnis enim res, quae dando non deficit,
Inst. f. Gesellschaftspolitik    dum habetur et non datur,
Kaulbachstr. 31a, 80539 München  nondum habetur, quomodo habenda est.
E-mail: goesele at hfph.mwn.de      (Augustinus)




More information about the R-help mailing list