4
$\begingroup$

I'm running a multiple linear regression with (amongst others) several categorical explanatory variables. My categorical variables are factors with several factor levels. For example, variable $x_1$ describes the number of residents in a dwelling and has the levels 1, 2 and >2. Another variable describes when the dwelling was built, so it exhibits levels like <1980, 1980-1989,... and so on.

Normally, using a linear model function, e.g. lm() in R, each categorical variable is reported as one variable in the ANOVA table. Only degrees of freedom are adjusted according to the number of factor levels. (I'm using R, but i assume this works similarly with other software.)

However, since I have to use a model function in R that does not support categorical variables (in plm() all variables have to be numeric), I included each factor level as dummy variable, e.g.

y ~ ... + (x_1 == "1") + (x_1 == "2") + (x_1 == ">2") + ...

The question:

Are ANOVA results from both cases - i.e. including categorical variables directly or turning them into dummy variables according to their factor levels - the same? Is the second method (model) actually correct?

$\endgroup$

1 Answer 1

2
$\begingroup$

Anova is really multiple regression for categorical variables, and is usually implemented via the use of dummy variables. Traditional formulas are only practical for a few, balanced designs. So the answer is YES---the answers are the same.

As for R's plm package and function, plm has a formula argument as is usual with R's modeling function, so your claim that all variables have to be numeric must be a misunderstanding.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.