# Caclulating the standard error of difference in Conditional Average Treatment Effects (CATEs)

Some perceive scientific information (for example, scientific evidence of climate change) as accurate, but others don't.

I want to know under which condition this biased evaluation increases or decreases.

To do so, I'm conducting a survey experiment, whose design is a 3 ("some conditions", 1, 2, or 3) X 2 (0 as conservative, or 1 as liberal) factorial design, that varied "some condition'', and political content of experiment vignette. Subjects are randomly assigned to one of six groups at equal probabilities.

treatment1 <- as.factor(c(1, 1, 1, 1, 2, 2, 1, 3, 1, 1, 2, 3, 1, 1, 2, 1, 2, 3, 2, 2, 1, 1, 2, 2, 2, 1, 3, 2, 2, 1))
treatment2 <- c(0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0)
covariate <- c(0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1)
outcome <- c(3.0, 4.5, 4.0, 3.0, 4.0, 5.0, 5.0, 4.0, 4.0, 3.5, 2.5, 4.5, 4.5, 6.0, 3.5, 3.0, 4.5, 3.5, 5.0, 3.5,  2.5, 5.0, 5.0, 4.0, 5.0, 4.5,4.5, 5.5, 3.5, 6.5)
df1 <- data.frame(treatment1, treatment2, covariate, outcome)
glimpse(df1)



I want to know if the differences in conditional average treatment effects (CATEs) of treatment 2 are statistically different between group 1 and group 2 or group 1 and group 3 in treatment 1.

$$ATE= E[Y_i(Z_2 = Liberal) - Y_i(Z_2 = Conservative)] \\ CATE_{X=1} = E[Y_i(Z_2 = Liberal, X = 1) - Y_i(Z_2 = Conservative, X = 1)] \\ CATE_{X=0} = E[Y_i(Z_2 = Liberal, X = 0) - Y_i(Z_2 = Conservative, X = 0)]$$

For sure, this can be captured using the regression model having three-way interaction coefficients between treatment factor variables and covariates,

df1 %>%
lm_robust(outcome ~ treatment1 * treatment2 * covariate, .)


However, I want to know the specific difference in CATEs in each three treatment1 groups and the standard errors and also the differences in the difference in CATEs across three treatment1 groups and these standard errors.

So far, I've computed the CATEs of a certain value of covariate and treatment1, which can be quite straightforward,

df1 %>%
filter(covariate == 1, treatment1 == 1) %>% lm_robust(outcome ~ treatment2, .)
df1 %>%
filter(covariate == 0, treatment1 == 1) %>% lm_robust(outcome ~ treatment2, .)
df1 %>%
filter(covariate == 1, treatment1 == 2) %>% lm_robust(outcome ~ treatment2, .)
df1 %>%
filter(covariate == 0, treatment1 == 2) %>% lm_robust(outcome ~ treatment2, .)
df1 %>%
filter(covariate == 1, treatment1 == 3) %>% lm_robust(outcome ~ treatment2, .)
df1 %>%
filter(covariate == 0, treatment1 == 3) %>% lm_robust(outcome ~ treatment2, .)


Question 1. Using the codes above, I can manually calculate each difference in CATEs. For example, when $$treatment1 = 1$$ , the difference in CATEs is |-1.166667 - (0.1)|. But I don't know how to impute its standard error. I think it is different from imputing standard error between two means.

Question 2. Furthermore, I want to know if the difference in CATEs is significantly different across the three treatment1 group. This can also be calculated manually, in the same regard, I can't impute the standard errors.

Please do not hesitate to ask if you have any questions. Thanks.