Search code examples
rlmdummy-variable

Dummy variables in R


I'm constructing a linear model to evaluate the effect of distances from a habitat boundary on the richness of an order of insects. There are some differences in equipment used so I am including equipment as a categorical variable to ensure that it hasn't had a significant affect on richness.

The categorical factor is 3 leveled so I asked r to produced dummy variables in the lm by using the code:

lm(Richness ~ Distances + factor(Equipment), data = Data) 

When I ask for the summary of the model I can see two of the levels with their coefficients. I am assuming that this means r is using one of the levels as the "standard" to compare the coefficients of the other levels to.

How can I find the coefficient for the third level in order to see what effect it has on the model?

Thank you


Solution

  • You can do lm(y~x-1) to remove the intercept, which in your case is the reference level of one of the factors. That being said, there are statistical reasons for using one of the levels as a reference.