Treatment Terms

DiffinDiffsBase.TermSetType
TermSet <: AbstractSet{AbstractTerm}

Wrapped Set{AbstractTerm} that specifies a collection of terms. Commonly used methods for Set work in the same way for TermSet.

Compared with StatsModels.TermOrTerms, it does not maintain order of terms but is more suitable for dynamically constructed terms.

DiffinDiffsBase.TermSetMethod
TermSet([itr])
TermSet(ts::Union{Int, Symbol, AbstractTerm}...)

Construct a TermSet from a collection of terms. Instead of passing an iterable collection, one may pass the terms as arguments directly. In the latter case, any Int or Symbol will be converted to a Term. See also termset, which is an alias for the constructor.

DiffinDiffsBase.TreatmentTermType
TreatmentTerm{T<:AbstractTreatment} <: AbstractTerm

A term that contains specifications on treatment and parallel trends assumption. See also treat.

Fields

  • sym::Symbol: the column name of data representing treatment status.
  • tr::T: a treatment type that specifies the causal parameters of interest.
  • pr::P: a parallel type that specifies the parallel trends assumption.
DiffinDiffsBase.parse_intercept!Method
parse_intercept(ts::TermSet)

Remove any ConstantTerm or InterceptTerm and return Boolean values indicating whether terms explictly requiring including/excluding the intercept exist.

This function is useful for obtaining a unique way of specifying the intercept before going through the schemaapply_schema pipeline defined in StatsModels.

DiffinDiffsBase.parse_treatMethod
parse_treat(formula::FormulaTerm)

Extract terms related to treatment specifications from formula.

Returns

  • TreatmentTerm: the unique TreatmentTerm contained in the formula.
  • TermSet: a set of terms that are interacted with the TreatmentTerm.
  • TermSet: a set of remaining terms in formula.rhs.

Error will be raised if either existence or uniqueness of the TreatmentTerm is violated.

DiffinDiffsBase.termsetMethod
termset([itr])
termset(ts::Union{Int, Symbol, AbstractTerm}...)

Construct a TermSet from a collection of terms. Instead of passing an iterable collection, one may pass the terms as arguments directly. In the latter case, any Int or Symbol will be converted to a Term.

DiffinDiffsBase.treatMethod
treat(s::Term, t::FunctionTerm{FT}, p::FunctionTerm{FP})

Construct a TreatmentTerm with fields set by s.sym, FT.instance(t.args_parsed...) and FP.instance(p.args_parsed...). This method is called by parse_treat(formula) when the formula is constructed by @formula.