3
$\begingroup$

I'm not sure if this is a question for StackOverflow or CrossValidated, as the question relates both to coding and statistics.

I have a panel data with information about sewage and water privatization in 82 municipalities between 1998 and 2020. For each year and municipality, I have the hospitalization per inhabitants for diseases caused by sanitation problems, such as diarrhea. The thing is, I only saw examples of two-way fixed effects with a UNIQUE treatment in a specific year but in my sample I have treatment in many periods.

Variables:

treatment: dummy measuring 1 for treated observations at some point in time, and 0 for the never treated group;

water: dummy measuring 1 after water privatization (post-treatment), 0 for never treated group or pre-treatment;

sewage: dummy measuring 1 after sewage privatization (post-treatment), 0 for never treated group or pre-treatment.

I've tried the code in R using the fixest package:

sanitation <- sanitation %>% mutate(
   treat_w = treatment*water,
   treat_s = treatment*sewage,
   treat_and = treatment*water*sewage,
   treat_or = treatment*ifelse(water==1 | sewage == 1 , 1, 0))

reg_1 <- feols( ratio_hospitalization ~ treat_w | year_ref + cod_mun, data = sanitation)
reg_2 <- feols( ratio_hospitalization ~ treat_s | year_ref + cod_mun, data = sanitation)
reg_3 <- feols( ratio_hospitalization ~ treat_and | year_ref + cod_mun, data = sanitation)
reg_4 <- feols( ratio_hospitalization ~ treat_or | year_ref + cod_mun, data = sanitation)

summary(reg_1)
summary(reg_2)
summary(reg_3)
summary(reg_4)

etable(reg_1, reg_2, reg_3, reg_4,
         vcov = "twoway", headers = c("Water", "Sewage", "Water and Sewage", "Water or Sewage"))

The results are shown in the image. R results

I'm not quite sure about it because all the examples I saw on the internet were with ONE treatment. Is it correct to use this code for multiple time treatments? Is there anyone here who can help me with this?

$\endgroup$
6
  • $\begingroup$ Welcome. Do you only have two treatments? If it’s more, than what does treatment represent? $\endgroup$ Jun 19, 2023 at 2:15
  • $\begingroup$ Hi Thomas! Maybe I said it wrong, the treatment is a dummy: 1 to the municipalities that have adopted privatization of water or sewage services (or both) during the period. What I meant is that the privatization occurred in different years. The treatment starts at different years for each municipality. For example in 2000 for A, in 2010 for B and C (treatment group), never for D (control group). $\endgroup$ Jun 20, 2023 at 4:06
  • $\begingroup$ I understand. So you want to assess the effect of water services, sewer services, and both services simultaneously in one equation? Do some municipalities receive both? $\endgroup$ Jun 20, 2023 at 6:22
  • $\begingroup$ I wanna estimate the effect of: only water, only sewage, water and sewage and water or sewage. Can be in different equations, idk which option works better. Yes, some municipalities received both, which means all the sanitation service was privitized. $\endgroup$ Jun 20, 2023 at 11:28
  • $\begingroup$ The setting where you want to know the effect of water or sewage services is just the effect of any treatment on the treated municipalities. It would make no distinction between the two treatments. Is this what you want as well? I am only asking because in one equation we can adjust for the other policies. In other words, we can assess the independent effect of one, or both, of these services on hospitalizations. Let me know and I can recommend some options for you. $\endgroup$ Jun 21, 2023 at 1:57

1 Answer 1

1
$\begingroup$

As I have gathered from reading your question and comments, you're interested in estimating the effect of multiple treatments simultaneously, even teasing out the effect of both treatments on hospitalizations.

The thing is, I only saw examples of two-way fixed effects with a UNIQUE treatment in a specific year but in my sample I have treatment in many periods.

The linear two-way fixed effects equation is very flexible. It can handle multiple treatments with different start (end) times. So let's imagine you have two policies. Some municipalities privatize water services; some municipalities privatize sewage services; some of them privatize all their sanitation services. It's appropriate to include the two policies in one equation. In fact, in a setting where you acquire data on all municipalities in a given country or region, this is desirable. We can assess the independent effect of one policy while adjusting for the other exposure(s). Moreover, it seems you've also expressed interest in assessing the effect of full privatization on hospitalizations as well. Here is one way to proceed:

$$ y_{it} = \gamma_i + \lambda_t + \delta_1W_{it} + \delta_2S_{it} + \delta_3 (W_{it} \times S_{it}) + \epsilon_{it}, $$

where $y_{it}$ is the hospitalization rate for municipality $i$ in year $t$. The parameters $\gamma_i$ and $\lambda_t$ denote fixed effects for municipalities and years, respectively. The policy (treatment) variables $W_{it}$ and $S_{it}$ equal 1 when a municipality privatizes their water and sewage services, respectively, 0 otherwise. The "control" municipalities remain consistently 0 since these treatments start at different times in different municipalities. The product of the two treatments assess the effect of full privatization.

Since I don't have access to your data, I simulated some fake data below:

# muni  = municipality identifier
# year  = year identifier
# treat = treatment/control dummy (time-invariant)
# y     = hospitalization rate (mostly random)

# water  = 1 in municipalities A (start 2013) and C (start 2015)
# sewage = 1 in municipalities B (start 2016) and C (start 2015)
# active = 1 for any treated municipality and in a post-treatment year

# A tibble: 40 × 7
   muni   year treat water sewage active     y
   <fct> <int> <dbl> <dbl>  <dbl>  <dbl> <dbl>
 1 A      2010     1     0      0      0  17.2
 2 A      2011     1     0      0      0  16.5
 3 A      2012     1     0      0      0  13.9
 4 A      2013     1     1      0      1  19.1
 5 A      2014     1     1      0      1  17.1
 6 A      2015     1     1      0      1  10.2
 7 A      2016     1     1      0      1  19.7
 8 A      2017     1     1      0      1  14.3
 9 A      2018     1     1      0      1  10.7
10 A      2019     1     1      0      1  17.0
11 B      2010     1     0      0      0  13.8
12 B      2011     1     0      0      0  12.9
13 B      2012     1     0      0      0  15.1
14 B      2013     1     0      0      0  12.4
15 B      2014     1     0      0      0  18.2
16 B      2015     1     0      0      0  15.1
17 B      2016     1     0      1      1  12.0
18 B      2017     1     0      1      1  17.0
19 B      2018     1     0      1      1  18.9
20 B      2019     1     0      1      1  12.0
21 C      2010     1     0      0      0  18.2
22 C      2011     1     0      0      0  10.0
23 C      2012     1     0      0      0  12.8
24 C      2013     1     0      0      0  18.0
25 C      2014     1     0      0      0  15.0
26 C      2015     1     1      1      1  14.1
27 C      2016     1     1      1      1  10.8
28 C      2017     1     1      1      1  10.7
29 C      2018     1     1      1      1  11.4
30 C      2019     1     1      1      1  13.5
31 D      2010     0     0      0      0  12.4
32 D      2011     0     0      0      0  14.4
33 D      2012     0     0      0      0  18.6
34 D      2013     0     0      0      0  15.5
35 D      2014     0     0      0      0  12.1
36 D      2015     0     0      0      0  18.5
37 D      2016     0     0      0      0  14.5
38 D      2017     0     0      0      0  10.6
39 D      2018     0     0      0      0  10.2
40 D      2019     0     0      0      0  13.2

Note how we have four municipalities observed over a 10-year period. Municipality "A" and "C" privatized water services. Municipality "B" and "C" privatized sewage services. Thus, municipality "C" is considered fully privatized by 2015 with both treatments active.

To proceed in R, it is perfectly fine to include the two treatment variables. Note, by running separate equations you're not being very honest about the contrasts you're making in the real world. For example, when you estimate a model with water only, do you exclude the municipalities with a sewage policy in effect? How do you disentangle the effects of the other policies on your outcome? Again, it is permissible to include more than one treatment variable.

Here is one way to proceed. Simply include both policies. By doing so, we can assess the independent effect of each treatment on the hospitalization rate. We can further separate out the effect of municipalities adopting both treatments by adding a third policy variable. You can achieve this by multiplying the two treatment variables, as suggested. The interaction returns the effect of the full privatization of sanitation services on hospitalizations.

# library(fixest)

mod_or  <- feols(y ~ water + sewage | muni + year, data = diddata)
mod_and <- feols(y ~ water * sewage | muni + year, data = diddata)

To be clear, the object mod_or is the effect of either policy on the outcome, while the object mod_and estimates the effect of both policies (i.e., water x sewage). Note how multiplying the water and sewage columns indexes the municipality where both treatments are active. Below is the etable() results:

                Water or Sewage Water and Sewage
Dependent Var.:               y                y
                                                
water                   -1.503          -0.0203 
                        (1.748)         (1.384) 
sewage                   0.9359          2.230  
                        (1.943)         (2.236) 
water x sewage                          -3.273* 
                                        (0.8985)
Fixed-Effects:          -------         --------
muni                        Yes              Yes
year                        Yes              Yes
_______________         _______         ________
S.E.: Clustered by: muni & year  by: muni & year
Observations                 40               40
R2                      0.23572          0.25671
Within R2               0.02484          0.05164
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The data frame also includes a third variable labeled active. This is equal to 1 when a municipality adopts any treatment and is in a post-treatment year, 0 otherwise. I would begin your analysis by estimating a separate equation with only this variable. Just note that it doesn't disambiguate between the two services; it returns a single summary measure of the causal effect of any privatized service on the hospitalization rate.

In short, you do not need to restrict your analysis to one treatment variable. If necessary, include them both! And, as has been noted by several econometricians, we should always be concerned that the proposed model is not robust to heterogeneous treatment effects. Not only may effects be changing over time, but they may be contaminated by the other treatments' effects. Chaisemartin and D'Haultfoeuille (2022) offer a neat treatise on this topic. Just familiarize yourself with their work so you're aware of the downsides.

$\endgroup$
3
  • $\begingroup$ Thank you so much Thomas! It helped me a lot! Including both treatments in the same regression changed my results and I think they're making much more sense now, since I´m not ignoring either water or sewage. I´m only a bit confused with my Water and Sewage result, both water and sewage are positives but Water x Sewage is negative, what does it mean? $\endgroup$ Jun 25, 2023 at 14:32
  • $\begingroup$ Is this not what you expect? Why wouldn’t full privatization reduce morbidity rates? I can’t answer these questions without more information. Was something else going on in the municipalities where there was full privatization that would have reduced hospitalizations, something unrelated to privatization policy? $\endgroup$ Jun 25, 2023 at 17:00
  • $\begingroup$ Yes. But for "mod_and" I've got water: 1.106**, sewage: 0.2455 and water x sewage: -1.099*. In total I have a positive effect of 0.2525, so the full privatizaion would increase mobidity rates no? I'm a bit confused about how to interpret it $\endgroup$ Jun 26, 2023 at 21:53

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.