Search code examples
rr-factor

Remove some factor-interaction terms from estimation


I'd like to remove certain factor interactions from an estimation. Here's an example with generated data from an imaginated labour market (I uploaded it here: http://pastebin.com/raw.php?i=EcMEVqUC)

s <- source("http://pastebin.com/raw.php?i=EcMEVqUC")$value

lm(income ~ age + cit * prof, data=s)

In this example economy, foreigners are not allowed to work in the public sector, therefore citforeign:profofficial is NA. Therefore I would like to exclude the interaction term of citforeign:profofficial. But keep all other interactions.

As I understand factors as multiple dummy variables stored in one column I don't think there's a logic problem with that?

(How) can I achieve this?

[edit]
A one step-solution would be great as I would want to use it with stepAIC()


Solution

  • Use function update.

    model1 <- lm(income ~ age + cit * prof, data=s)
    model2 <- update(model1, . ~ . - citforeign:profofficial)