9

what I am interested in learning is how to calculate the std error of the marginal effects of a X variable when it is part of an interaction, especially in robust regression.

There are tipically two cases that interest me: when there is an interaction between two continuous variables and when there is an interaction between a continuous and a binary variable. Let's our model be a simple one:

$Y= b_0 + b_1X + b_2Z + b_3XZ + e$

I know how to calculate the marginal effect of X in both cases, but not how to calculate its standard error. Please, any hints on how to do this, both theoretically or in R code, may be very helpfull.

Peter Ellis
  • 16,522
  • 1
  • 44
  • 82
R.Astur
  • 1,047
  • 1
  • 9
  • 14
  • I suspect your model is more complicated than the one you present. That model is just a linear model, so the marginal effect is b_3 and its standard error is typically directly returned by your estimation command. – Maarten Buis Apr 11 '13 at 06:56
  • 2
    Hi Maarten, thanks for your comment. I edited the question to better reflecft what I want, as I was talking about the marginal effect of X, which in this case i not b_3, but b_1 + b_3*Z. Does it get clearer? Thanks again – R.Astur Apr 12 '13 at 21:33

1 Answers1

8

If you treat $Z$ as non-random variable, then the marginal effect is $b_1 + b_3 \cdot Z$, a function of $Z$. The variance of a weighted sum is $Var(b_1) + Var(b_3) \cdot Z^2 + 2 \cdot Z \cdot Cov(b_1,b_3),$ and the standard error is just the square root of that. You can get the covariance from the right off-diagonal element of the variance-covariance matrix of the coefficients. The variances will be found on the diagonal.

If your software does not return it, you can estimate the variance-covariance matrix as \begin{equation}V=\frac{\hat e'\hat e}{n-k}(D'D)^{-1},\end{equation}

where $\hat e$ is the vector of residuals $\hat e=y-\hat \beta'D$, and the $D$ matrix contains a column of ones, $X$, $Z$ and their interaction, $n$ is the number of observations and $k$ is the number of variables.


dimitriy
  • 31,081
  • 5
  • 63
  • 138
  • Fantastic. Would it also apply to robust regression (although, I can imagine that calculating IC with those std errors would have to assume a distribution not necessarily normal when using robust regression)? – R.Astur Apr 12 '13 at 22:35
  • The formula for a heteroskedasticity-robust variance matrix is more complicated, but the rest is the same. – dimitriy Apr 12 '13 at 22:48