@@ -93,16 +93,16 @@ and a group that did not receive any treatment in any sample period.
93
93
See also [`nevertreated`](@ref).
94
94
95
95
# Fields
96
- - `e::Vector{Int }`: group indices for units that did not receive any treatment.
96
+ - `e::Tuple{Vararg{TimeType} }`: group indices for units that did not receive any treatment.
97
97
- `c::C`: an instance of [`ParallelCondition`](@ref).
98
98
- `s::S`: an instance of [`ParallelStrength`](@ref).
99
99
"""
100
100
struct NeverTreatedParallel{C,S} <: TrendParallel{C,S}
101
- e:: Vector{Int }
101
+ e:: Tuple{Vararg{TimeType} }
102
102
c:: C
103
103
s:: S
104
104
function NeverTreatedParallel (e, c:: ParallelCondition , s:: ParallelStrength )
105
- e = unique! (sort! ([e... ]))
105
+ e = ( unique! (sort! ([e... ])) ... , )
106
106
isempty (e) && error (" field `e` cannot be empty" )
107
107
return new {typeof(c),typeof(s)} (e, c, s)
108
108
end
@@ -111,11 +111,12 @@ end
111
111
istreated (pr:: NeverTreatedParallel , x) = ! (x in pr. e)
112
112
113
113
show (io:: IO , pr:: NeverTreatedParallel ) =
114
- print (IOContext (io, :compact => true ), " NeverTreated{" , pr. c, " ," , pr. s, " }(" , pr. e, " )" )
114
+ print (IOContext (io, :compact => true ), " NeverTreated{" , pr. c, " ," , pr. s, " }" ,
115
+ length (pr. e)== 1 ? string (" (" , pr. e[1 ], " )" ) : pr. e)
115
116
116
117
function show (io:: IO , :: MIME"text/plain" , pr:: NeverTreatedParallel )
117
118
println (io, pr. s, " trends with any never-treated group:" )
118
- print (io, " Never-treated groups: " , pr. e)
119
+ print (io, " Never-treated groups: " , join ( string .( pr. e), " , " ) )
119
120
pr. c isa Unconditional || print (io, " \n " , pr. c)
120
121
end
121
122
@@ -133,14 +134,14 @@ a wrapper method of `nevertreated` calls this method.
133
134
```jldoctest; setup = :(using DiffinDiffsBase)
134
135
julia> nevertreated(-1)
135
136
Parallel trends with any never-treated group:
136
- Never-treated groups: [-1]
137
+ Never-treated groups: -1
137
138
138
139
julia> typeof(nevertreated(-1))
139
- NeverTreatedParallel{Unconditional,Exact,Tuple{Int64} }
140
+ NeverTreatedParallel{Unconditional,Exact}
140
141
141
142
julia> nevertreated([-1, 0])
142
143
Parallel trends with any never-treated group:
143
- Never-treated groups: [ -1, 0]
144
+ Never-treated groups: -1, 0
144
145
145
146
julia> nevertreated([-1, 0]) == nevertreated(-1:0) == nevertreated(Set([-1, 0]))
146
147
true
@@ -167,8 +168,8 @@ and any group that received the treatment relatively late (or never receved).
167
168
See also [`notyettreated`](@ref).
168
169
169
170
# Fields
170
- - `e::Vector{Int }`: group indices for units that received the treatment relatively late.
171
- - `ecut::Vector{Int }`: user-specified period(s) when units in a group in `e` started to receive treatment.
171
+ - `e::Tuple{Vararg{TimeType} }`: group indices for units that received the treatment relatively late.
172
+ - `ecut::Tuple{Vararg{TimeType} }`: user-specified period(s) when units in a group in `e` started to receive treatment.
172
173
- `c::C`: an instance of [`ParallelCondition`](@ref).
173
174
- `s::S`: an instance of [`ParallelStrength`](@ref).
174
175
@@ -178,14 +179,14 @@ See also [`notyettreated`](@ref).
178
179
- the sample has a rotating panel structure with periods overlapping with some others.
179
180
"""
180
181
struct NotYetTreatedParallel{C,S} <: TrendParallel{C,S}
181
- e:: Vector{Int }
182
- ecut:: Vector{Int }
182
+ e:: Tuple{Vararg{TimeType} }
183
+ ecut:: Tuple{Vararg{TimeType} }
183
184
c:: C
184
185
s:: S
185
186
function NotYetTreatedParallel (e, ecut, c:: ParallelCondition , s:: ParallelStrength )
186
- e = unique! (sort! ([e... ]))
187
+ e = ( unique! (sort! ([e... ])) ... , )
187
188
isempty (e) && error (" field `e` cannot be empty" )
188
- ecut = unique! (sort! ([ecut... ]))
189
+ ecut = ( unique! (sort! ([ecut... ])) ... , )
189
190
isempty (ecut) && error (" field `ecut` cannot be empty" )
190
191
return new {typeof(c),typeof(s)} (e, ecut, c, s)
191
192
end
@@ -194,12 +195,13 @@ end
194
195
istreated (pr:: NotYetTreatedParallel , x) = ! (x in pr. e)
195
196
196
197
show (io:: IO , pr:: NotYetTreatedParallel ) =
197
- print (IOContext (io, :compact => true ), " NotYetTreated{" , pr. c, " ," , pr. s, " }(" , pr. e, " )" )
198
+ print (IOContext (io, :compact => true ), " NotYetTreated{" , pr. c, " ," , pr. s, " }" ,
199
+ length (pr. e)== 1 ? string (" (" , pr. e[1 ], " )" ) : pr. e)
198
200
199
201
function show (io:: IO , :: MIME"text/plain" , pr:: NotYetTreatedParallel )
200
202
println (io, pr. s, " trends with any not-yet-treated group:" )
201
- println (io, " Not-yet-treated groups: " , pr. e)
202
- print (io, " Treated since: " , pr. ecut)
203
+ println (io, " Not-yet-treated groups: " , join ( string .( pr. e), " , " ) )
204
+ print (io, " Treated since: " , join ( string .( pr. ecut), " , " ) )
203
205
pr. c isa Unconditional || print (io, " \n " , pr. c)
204
206
end
205
207
@@ -218,21 +220,21 @@ a wrapper method of `notyettreated` calls this method.
218
220
```jldoctest; setup = :(using DiffinDiffsBase)
219
221
julia> notyettreated(5)
220
222
Parallel trends with any not-yet-treated group:
221
- Not-yet-treated groups: [5]
222
- Treated since: [5]
223
+ Not-yet-treated groups: 5
224
+ Treated since: 5
223
225
224
226
julia> typeof(notyettreated(5))
225
- NotYetTreatedParallel{Unconditional,Exact,Tuple{Int64},Tuple{Int64} }
227
+ NotYetTreatedParallel{Unconditional,Exact}
226
228
227
229
julia> notyettreated([-1, 5, 6], 5)
228
230
Parallel trends with any not-yet-treated group:
229
- Not-yet-treated groups: [ -1, 5, 6]
230
- Treated since: [5]
231
+ Not-yet-treated groups: -1, 5, 6
232
+ Treated since: 5
231
233
232
234
julia> notyettreated([4, 5, 6], [4, 5, 6])
233
235
Parallel trends with any not-yet-treated group:
234
- Not-yet-treated groups: [ 4, 5, 6]
235
- Treated since: [ 4, 5, 6]
236
+ Not-yet-treated groups: 4, 5, 6
237
+ Treated since: 4, 5, 6
236
238
```
237
239
"""
238
240
notyettreated (e, ecut, c:: ParallelCondition , s:: ParallelStrength ) =
0 commit comments