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.