[R] car::linearHypothesis fails to constrain factor to zero

Iuri Gavronski iuri at ufrgs.br
Wed Aug 15 13:47:01 CEST 2012


Hi,

I am trying to test whether a factor (coded as a set of dummy
variables) is equal to zero, using linearHypothesis. I get an error.
See a reproducible example:

data(swiss)
my_swiss = swiss
my_swiss$fake = factor(sample(c("A","B"),47,rep=T))
my_lm <- lm(Infant.Mortality ~ Fertility + fake, data=my_swiss)

> linearHypothesis(my_lm, "fake")
Error in constants(lhs, cnames_symb) :
  The hypothesis "fake" is not well formed: contains bad
coefficient/variable names.
In addition: Warning message:
In constants(lhs, cnames_symb) : NAs introduced by coercion
>



More information about the R-help mailing list