I have performed mixed effect Cox hazard regressions, and reconstructed the slopes to get group specific slopes (e.g. sex-specific responses to the explanatory variable). I aim to test whether the slopes differ from one another (e.g. do males and females respond differently to the explanatory variable?). To do this I will use Z-tests (here and here) where
$$Z= \frac{\beta_1-\beta_2}{\sqrt{{SE_{\beta_1}}^{2}+{SE_{\beta_2}}^2}}$$
However, I have performed my models in R using the coxme package which gives the following output, from which I reconstruct the sex- and group-specific slopes with the included function.
...
Fixed coefficients
coef exp(coef) se(coef) z p
SexM 0.091305017 1.0956031 0.09085235 1.00 0.31
GroupG2 -0.036313825 0.9643376 0.08889039 -0.41 0.68
NE -0.192009224 0.8252993 0.01317388 -14.57 0.00
SexM:GroupG2 0.009757875 1.0098056 0.12750426 0.08 0.94
SexM:NE -0.212264676 0.8087506 0.02008058 -10.57 0.00
GroupG2:NE -0.006933708 0.9930903 0.01814987 -0.38 0.70
SexM:GroupG2:NE 0.044999019 1.0460268 0.02756553 1.63 0.10
...
coxSlopeFunc = function(model, nfixed = 1){
if(nfixed ==1){
# Slope for Females + G1
FG1 = model$coefficients[3]
# Slope for Males + G1
MG1 = model$coefficients[3] + model$coefficients[5]
# Slope for Females + G2
FG2 = model$coefficients[3] + model$coefficients[6]
# Slope for Males + G2
MG2 = model$coefficients[3] + model$coefficients[5] + model$coefficients[6] + model$coefficients[7]
# Sex differences in slope
SG1 = FG1 - MG1
SG2 = FG2 - MG2
matrix(c(FG1,MG1,FG2,MG2,SG1,SG2), ncol = 1, byrow = T)}
}
round(coxSlopeFunc(coxdum),3)
> round(coxSlopeFunc(coxdum),3)
[,1]
[1,] -0.192
[2,] -0.404
[3,] -0.199
[4,] -0.366
[5,] 0.212
[6,] 0.167
However, I am unsure how to calculate the SE of the slope for each - should I just sum the standard errors of the components?
$$\frac{(-0.192009224 - (-0.192009224 + -0.212264676))}{\sqrt{0.01317388^2 + (0.01317388 + 0.02008058)^2}}$$