I'd like to estimate the unique effects for each variable in a linear model, however I am unsure if I calculating these correctly.
I am using a model estimated using each of the variables in my data plus a
binary interaction with each variable, e.g. y ~ x + x:z
where x is a vector and
z is two factors which is present in x. Doing this in R I believe a two levels factor is simply c(0,1).
From what understand I can calculate the individual effects of the variables for each case of the binary interaction term is as follows:
- When the interaction term is 0, the variable effect of x on y is the estimated model coefficient for x
- When the interaction term is 1, the variable effect of x on y is the estimated model coefficient for x plus the coefficient for the interaction term of x:z
Assuming this is correct I would also like to calculate the standard errors
associated with the each effect. I looked at this question which states
that the associated standard errors can be calculated as follows sqrt(x + x:z +
2*cov(x,x:z))
. This however produces much smaller standard errors compared to
the non-interaction term effects. This makes me assume I am doing something
wrong. Could you tell me the correct way to estimate these effects?