8
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Maarten Buis Apr 11 '13 at 6:56
  • 2
    $\begingroup$ 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 $\endgroup$ – R.Astur Apr 12 '13 at 21:33
8
$\begingroup$

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.


| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ 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)? $\endgroup$ – R.Astur Apr 12 '13 at 22:35
  • $\begingroup$ The formula for a heteroskedasticity-robust variance matrix is more complicated, but the rest is the same. $\endgroup$ – Dimitriy V. Masterov Apr 12 '13 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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