1
$\begingroup$

I am currently working on an AB/BA cross-over study. There I have a treatment $T$, a time-varying covariate $X$ and a dummy variables $Z$. I wish to study the interaction between $X$ and $T, Z$. I also have some time-varying covariates $W$ that I wish to adjust for.

I assume the following linear model for the outcome $Y$:

$$Y = \beta_0 + \beta_1 T + \beta_2 X + \beta_3 XT+\beta_4W+\beta_5Z+ \beta_6XZ + \beta_7ZT + \beta_8XZT+\varepsilon $$

Denote $X_T$ and $X_C$ for the value $X$ takes at the treatment and control occasions respectively, with the corresponding definitions for $W_T$ and $W_C$ as well as for $Y_T$ and $Y_C$. I take the difference between the outcome at the treatment and control occasions and get $$Y_T - Y_C = \beta_1 + \beta_2(X_T - X_C) + \beta_3 X_T + \beta_4(W_T - W_C) + \beta_6 Z (X_T - X_C) + \beta_7 Z + \beta_8 ZX_T +\varepsilon^*$$

Thus linear regression of $Y_T - Y_C$ on $X_T-X_C$, $X_T$, $W_T-W_C$, $Z(X_T-X_C)$, $Z$ and $ZX_T$ yields identification of some of the parameters in the model.

Now, the coefficients of a model with interactions are always more complicated to interprete than those of a model without, so I want to also present the marginal effect of $X$ for different values of $Z$ and $T$. That is, I want to determine $\frac{\delta(Y_T-Y_C)}{\delta X}$ and get confidence intervals for those marginal effects of $X$ on $Y$ at different values of my dummy variables.

Had I had a more traditional linear regression model, I could have gotten this through the margins package in R. However, as $X$ is, in some sense, split into the $X_T$ and $X_C$ parts, said package can not (to my knowledge) be used for what I seek. I can get the manual point estimates by just adding the corresponding coefficients for the cases where $Z,T$ are 0 or 1, but the confidence intervals are proving tricky. Any suggestions would be much appreciated.

$\endgroup$

1 Answer 1

0
$\begingroup$

Turns out that the solution is pretty straight-forward. The point estimates, as I alluded to earlier, are gotten by simply taking the derivative and plugging in the corresponding value of $Z$ (and indirectly of $T$) in question. For instance, the marginal effect of $X$ on $Y$ when $T = 1$ and $Z = 0$ is simply $\beta_2 + \beta_3$, and the marginal effect when $T = 0$ and $Z = 1$ is $\beta_2 + \beta_6$. Replacing those parameters with their estimated counterparts from the regression model gives the point estimate of the marginal effect of $X$ on $Y$.

As for the standard errors, we get them by using rules for variance and covariance. For example: $Var\left(\hat{\beta}_2 + \hat{\beta}_3\right) = Var\left(\hat{\beta}_2\right) + Var\left(\hat{\beta}_3\right) + 2Cov\left(\hat{\beta}_2, \hat{\beta}_3\right)$.

From there we can construct confidence intervals via the normal or t-distributions as per usual.

$\endgroup$
1
  • $\begingroup$ I would also like to point out that the glht function from the multcomp package in R comes with this functionality. $\endgroup$
    – Phil
    Commented Apr 2, 2019 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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