2

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()

4

1 回答 1

2

使用功能update

model1 <- lm(income ~ age + cit * prof, data=s)
model2 <- update(model1, . ~ . - citforeign:profofficial)
于 2013-06-04T09:35:08.907 回答