DiffinDiffsBase.AbstractDIDResultType
AbstractDIDResult{TR<:AbstractTreatment} <: StatisticalModel

Interface supertype for all types that collect estimation results for difference-in-differences with treatment of type TR.

Interface definition

Required methodDefault definitionBrief description
coef(r)r.coefVector of point estimates for all coefficients including covariates
vcov(r)r.vcovVariance-covariance matrix for estimates in coef
vce(r)r.vceCovariance estimator
confint(r)Based on t or normal distributionConfidence interval for estimates in coef
treatment(r)r.trTreatment specification
nobs(r)r.nobsNumber of observations (table rows) involved in estimation
outcomename(r)r.ynameName of the outcome variable
coefnames(r)r.coefnamesNames (Vector{String}) of all coefficients including covariates
treatcells(r)r.treatcellsTables.jl-compatible tabular description of treatment coefficients in the order of coefnames (without covariates)
weights(r)r.weightsName of the column containing sample weights (if specified)
ntreatcoef(r)size(treatcells(r), 1)Number of treatment coefficients
treatcoef(r)view(coef(r), 1:ntreatcoef(r))A view of treatment coefficients
treatvcov(r)(N = ntreatcoef(r); view(vcov(r), 1:N, 1:N))A view of variance-covariance matrix for treatment coefficients
treatnames(r)coefnames(r)[1:ntreatcoef(r)]Names (Vector{String}) of treatment coefficients
Optional methods
parent(r)r.parent or rResult object from which r is generated
dof_residual(r)r.dof_residual or nothingResidual degrees of freedom
responsename(r)outcomename(r)Name of the outcome variable
coefinds(r)r.coefinds or nothingLookup table (Dict{String,Int}) from coefnames to integer indices (for retrieving estimates by name)
ncovariate(r)length(coef(r)) - ntreatcoef(r)Number of covariate coefficients
DiffinDiffsBase.AggregatedDIDResultType
AggregatedDIDResult{TR,P<:DIDResult} <: AbstractDIDResult{TR}

Supertype for all types that collect estimation results aggregated from a DIDResult of type P with treatment of type TR.

DiffinDiffsBase.ApproximateType
Approximate <: ParallelStrength

Supertype for all types assuming some notion of parallel holds approximately.

DiffinDiffsBase.CovariateConditionalType
CovariateConditional <: ParallelCondition

Supertype for all types assuming some notion of parallel holds after conditioning on covariates.

DiffinDiffsBase.DefaultDIDType
DefaultDID <: DiffinDiffsEstimator

Default difference-in-differences estimator selected based on the context.

DiffinDiffsBase.DynamicTreatmentType
DynamicTreatment{S<:TreatmentSharpness} <: AbstractTreatment

Specify an absorbing binary treatment with effects allowed to evolve over time. See also dynamic.

Fields

  • time::Symbol: column name of data representing calendar time.
  • exc::Tuple{Vararg{Int}}: excluded relative time.
  • s::S: an instance of TreatmentSharpness.
DiffinDiffsBase.NeverTreatedParallelType
NeverTreatedParallel{C,S} <: TrendParallel{C,S}

Assume a parallel trends assumption holds between any group that received the treatment during the sample periods and a group that did not receive any treatment in any sample period. See also nevertreated.

Fields

  • e::Tuple{Vararg{ValidTimeType}}: group indices for units that did not receive any treatment.
  • c::C: an instance of ParallelCondition.
  • s::S: an instance of ParallelStrength.
DiffinDiffsBase.NotYetTreatedParallelType
NotYetTreatedParallel{C,S} <: TrendParallel{C,S}

Assume a parallel trends assumption holds between any group that received the treatment relatively early and any group that received the treatment relatively late (or never receved). See also notyettreated.

Fields

  • e::Tuple{Vararg{ValidTimeType}}: group indices for units that received the treatment relatively late.
  • ecut::Tuple{Vararg{ValidTimeType}}: user-specified period(s) when units in a group in e started to receive treatment or show anticipation effects.
  • c::C: an instance of ParallelCondition.
  • s::S: an instance of ParallelStrength.
Note

ecut could be different from minimum(e) if

  • never-treated groups are included and use indices with smaller values;
  • the sample has a rotating panel structure with periods overlapping with some others.
DiffinDiffsBase.PanelStructureType
PanelStructure{R<:Signed, IP<:AbstractVector, TP<:AbstractVector}

Panel data structure defined by unique combinations of unit ids and time periods. It contains the information required for certain operations such as lag and diff. See also setpanel.

Fields

  • refs::Vector{R}: reference values that allow obtaining time gaps by taking differences.
  • invrefs::Dict{R, Int}: inverse map from refs to indices.
  • idpool::IP: unique unit ids.
  • timepool::TP: sorted unique time periods.
  • laginds::Dict{Int, Vector{Int}}: a map from lag distances to vectors of indices of lagged values.
DiffinDiffsBase.RotatingTimeArrayType
RotatingTimeArray{T<:RotatingTimeValue,N,C,I} <: AbstractArray{T,N}

Array type for RotatingTimeValues that stores the field values rotation and time in two arrays for efficiency. The two arrays that hold the field values for all elements can be accessed as properties.

DiffinDiffsBase.RotatingTimeValueType
RotatingTimeValue{R, T}

A wrapper around a time value for distinguishing potentially different rotation group it could belong to in a rotating sampling design. See also rotatingtime and settime.

Fields

  • rotation::R: a rotation group in a rotating sampling design.
  • time::T: a time value belonged to the rotation group.
DiffinDiffsBase.ScaledArrayType
ScaledArray{T,R,N,RA,P} <: AbstractArray{T,N}

Array type that stores data as indices of a range.

Fields

  • refs::RA<:AbstractArray{R,N}: an array of indices.
  • pool::P<:AbstractRange: a range that covers all possible values stored by the array.
  • invpool::Dict{T,R}: a map from array elements to indices of pool.
DiffinDiffsBase.ScaledArrayType
ScaledArray(x::AbstractArray, start, step[, stop]; reftype=Int32, usepool=true)
ScaledArray(x::AbstractArray, step; reftype=Int32, start, stop, usepool=true)

Construct a ScaledArray from x given the step size. If start or stop is not specified, it will be chosen based on the extrema of x.

Keywords

  • reftype::Type=Int32: the element type of field refs.
  • usepool::Bool=true: find extrema of x based on DataAPI.refpool.
DiffinDiffsBase.TableIndexedMatrixType
TableIndexedMatrix{T,M,R,C} <: AbstractMatrix{T}

Matrix with row and column indices that can be selected based on row values in a Tables.jl-compatible table respectively. This is useful when how elements are stored into the matrix are determined by the rows of the tables.

Parameters

  • T: element type of the matrix.
  • M: type of the matrix.
  • R: type of the table paired with the row indices.
  • C: type of the table paired with the column indices.

Fields

  • m::M: the matrix that stores the elements.
  • r::R: a table with the same number of rows with m.
  • c::C: a table of which the number of rows is equal to the number of columns of m.
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.TransSubDIDResultType
TransSubDIDResult{TR,P,M,I,TI} <: AbstractDIDResult{TR}

Estimation results obtained from a linear transformation of a subset of coefficient estimates from DIDResult. See also TransformedDIDResult, lincom and rescale.

Parameters

  • P: type of the result that is transformed.
  • M: type of the matrix representing the linear transformation.
  • I: type of indices for all coefficients.
  • TI: type of indices for treatment coefficients.
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.TrendParallelType
TrendParallel{C,S} <: AbstractParallel{C,S}

Supertype for all parallel types that assume a parallel trends assumption holds over all the relevant time periods.

DiffinDiffsBase.UnspecifiedParallelType
UnspecifiedParallel{C,S} <: AbstractParallel{C,S}

A parallel trends assumption (PTA) without explicitly specified relations across treatment groups. See also unspecifiedpr.

With this parallel type, operations for complying with a PTA are suppressed. This is useful, for example, when the user-provided regressors and sample restrictions need to be accepted without any PTA-specific alteration.

Fields

DiffinDiffsBase.VecColumnTableType
VecColumnTable <: AbstractColumns

A Tables.jl-compatible column table that stores data as Vector{AbstractVector} and column names as Vector{Symbol}. Retrieving columns by column names is achieved with a Dict{Symbol,Int} that maps names to indices.

This table type is designed for retrieving and iterating dynamically generated columns for which specialization on names and order of columns are not desired. It is not intended to be directly constructed for interactive usage.

Base.diffMethod
diff(panel::PanelStructure, v::AbstractArray; kwargs...)

Return the differences of v within observations for each unit in panel. By default, it calculates the first differences. See also diff!.

Keywords

  • order::Integer=1: the order of differences to be taken.
  • l::Integer=1: the time interval between each pair of observations.
  • default=missing: default values for indices where the differences do not exist.
Base.parentMethod
parent(r::AbstractDIDResult)

Return the AbstractDIDResult from which r is generated.

Base.viewMethod
view(r::AbstractDIDResult, inds)

Return a SubDIDResult that lazily references elements from r at the given index or indices inds without constructing a copied subset.

DiffinDiffsBase._treatnamesMethod
_treatnames(treatcells)

Generate names for treatment coefficients. Assume treatcells is compatible with the Tables.jl interface.

DiffinDiffsBase.alignMethod
align(xs::AbstractArray, sa::ScaledArrOrSub)

Convert xs into a ScaledArray with a pool that has the same first element and step size as the pool from sa.

DiffinDiffsBase.aligntimeMethod
aligntime(col::AbstractArray, time::ScaledArrOrSub)
aligntime(col::AbstractArray, time::RotatingTimeArray)
aligntime(data, colname::Union{Symbol,Integer}, timename::Union{Symbol,Integer})

Convert a column of time values col to a ScaledArray with a pool that has the same first element and step size as the pool from the ScaledArray time. If time is a RotatingTimeArray with the time field being a ScaledArray, the returned array is also a RotatingTimeArray with the time field being the converted ScaledArray. Alternative, the arrays may be specified with a Tables.jl-compatible data table and column indices colname and timename. See also settime.

This is useful for representing all discretized time periods with the same scale so that the underlying reference values returned by DataAPI.refarray can be directly comparable across the columns.

DiffinDiffsBase.applyMethod
apply(d, by::Pair)

Apply a function elementwise to the specified column(s) in a Tables.jl-compatible table d and return the result.

Depending on the argument(s) accepted by a function f, it is specified with argument by as either column_index => f or column_indices => f where column_index is either a Symbol or Int for a column in d and column_indices is an iterable collection of such indices for multiple columns. f is applied elementwise to each specified column to obtain an array of returned values.

DiffinDiffsBase.apply_and!Method
apply_and!(inds::BitVector, d, by::Pair)
apply_and!(inds::BitVector, d, bys::Pair...)

Apply a function that returns true or false elementwise to the specified column(s) in a Tables.jl-compatible table d and then update the elements in inds through bitwise and with the returned array. If an array instead of a function is provided, elementwise equality (==) comparison is applied between the column and the array. See also apply_and.

The way a function is specified is the same as how it is done with apply. If multiple Pairs are provided, inds are updated for each returned array through bitwise and.

DiffinDiffsBase.apply_andMethod
apply_and(d, by::Pair)
apply_and(d, bys::Pair...)

Apply a function that returns true or false elementwise to the specified column(s) in a Tables.jl-compatible table d and return the result. If an array instead of a function is provided, elementwise equality (==) comparison is applied between the column and the array. See also apply_and!.

The way a function is specified is the same as how it is done with apply. If multiple Pairs are provided, the returned array is obtained by combining arrays returned by each function through bitwise and.

DiffinDiffsBase.cellrowsMethod
cellrows(cols::VecColumnTable, refrows::IdDict)

A utility function for processing the object refrows returned by findcell. Unique row values from cols corresponding to the keys in refrows are sorted lexicographically and stored as rows in a new VecColumnTable. Groups of row indices from the values of refrows are permuted to match the order of row values and collected in a Vector.

Returns

  • cells::VecColumnTable: unique row values from columns in cols.
  • rows::Vector{Vector{Int}}: row indices for each combination.
DiffinDiffsBase.checkdata!Method
checkdata!(args...)

Check data is Tables.AbstractColumns-compatible and find valid rows for options subset and weightname. See also CheckData.

DiffinDiffsBase.checktreatindexMethod
checktreatindex(inds, tinds)

Check whether all indices for treatment coefficients tinds are positioned before any other index in inds. This is required to be true for methods such as treatcoef and treatvcov to work properly. If the test fails, an ArgumentError exception is thrown.

DiffinDiffsBase.checkvars!Method
checkvars!(args...)

Exclude rows with missing data or violate the overlap condition and find rows with data from treated units. See also CheckVars.

DiffinDiffsBase.coefindsMethod
coefinds(r::AbstractDIDResult)

Return the map from coefficient names to integer indices for retrieving estimates by name.

DiffinDiffsBase.diff!Method
diff!(dest::AbstractArray, panel::PanelStructure, v::AbstractArray; kwargs...)

Take the differences of v within observations for each unit in panel and store the result in dest. By default, it calculates the first differences. See also diff.

Keywords

  • order::Integer=1: the order of differences to be taken.
  • l::Integer=1: the time interval between each pair of observations.
  • default=missing: default values for indices where the differences do not exist.
DiffinDiffsBase.dynamicFunction
dynamic(time::Symbol, exc, s::TreatmentSharpness=sharp())

Construct a DynamicTreatment with fields set by the arguments. By default, s is set as SharpDesign. When working with @formula, a wrapper method of dynamic calls this method.

Examples

julia> dynamic(:month, -1)
Sharp dynamic treatment:
  column name of time variable: month
  excluded relative time: -1

julia> typeof(dynamic(:month, -1))
DynamicTreatment{SharpDesign}

julia> dynamic(:month, -3:-1)
Sharp dynamic treatment:
  column name of time variable: month
  excluded relative time: -3, -2, -1

julia> dynamic(:month, [-2,-1], sharp())
Sharp dynamic treatment:
  column name of time variable: month
  excluded relative time: -2, -1
DiffinDiffsBase.exampledataMethod
exampledata(name::Union{Symbol,String})

Return a CSV.File containing the example dataset with the specified name.

DiffinDiffsBase.findcellMethod
findcell(cols::VecColumnTable)
findcell(names, data, esample=Colon())

Group the row indices of a collection of data columns so that the combination of row values from these columns are the same within each group.

Instead of directly providing the relevant portions of columns as VecColumnTable`, one may specify thenamesof columns fromdataof anyTables.jl-compatible table type over selected rows indicated byesample. Note that unlessesamplecovers all rows ofdata, the row indices are those for the subsample selected based onesamplerather than those for the fulldata`.

Returns

  • IdDict{Tuple, Vector{Int}}: a map from unique row values to row indices.
DiffinDiffsBase.findlag!Function
findlag!(panel::PanelStructure, l::Integer=1)

Construct a vector of indices of the lth lagged values for all id-time combinations of panel and save the result in panel.laginds. If a lagged value does not exist, its index is filled with 0. See also ilag!.

DiffinDiffsBase.findlead!Function
findlead!(panel::PanelStructure, l::Integer=1)

Construct a vector of indices of the lth lead values for all id-time combinations of panel and save the result in panel.laginds. If a lead value does not exist, its index is filled with 0. See also ilead!.

DiffinDiffsBase.ilag!Function
ilag!(panel::PanelStructure, l::Integer=1)

Return a vector of indices of the lth lagged values for all id-time combinations of panel. The indices are retrieved from panel if they have been collected before. Otherwise, they are created by calling findlag!. See also ilead!.

DiffinDiffsBase.ilead!Function
ilead!(panel::PanelStructure, l::Integer=1)

Return a vector of indices of the lth lead values for all id-time combinations of panel. The indices are retrieved from panel if they have been collected before. Otherwise, they are created by calling findlead!. See also ilag!.

DiffinDiffsBase.istreatedFunction
istreated(pr::TrendParallel, x)

Test whether x represents the treatment time for a group of units that are not treated. See also istreated!.

DiffinDiffsBase.istreated!Function
istreated!(out::AbstractVector{Bool}, pr::TrendParallel, x::AbstractArray)

For each element in x, test whether it represents the treatment time for a group of units that are not treated and save the result in out. See also istreated.

DiffinDiffsBase.lincomFunction
lincom(r::AbstractDIDResult, linmap::AbstractMatrix{<:Real}, subset=nothing)

Linearly transform the coefficient estimates from DID result r through a matrix linmap. The number of columns of linmap must match the total number of coefficients from r. If linmap is not square (with fewer rows than columns), subset must be specified with indices representing coefficients that remain after the transformation. See also rescale.

DiffinDiffsBase.nevertreatedMethod
nevertreated(e, c::ParallelCondition, s::ParallelStrength)
nevertreated(e; c=Unconditional(), s=Exact())

Construct a NeverTreatedParallel with fields set by the arguments. By default, c is set as Unconditional() and s is set as Exact(). When working with @formula, a wrapper method of nevertreated calls this method.

Examples

julia> nevertreated(-1)
Parallel trends with any never-treated group:
  Never-treated groups: -1

julia> typeof(nevertreated(-1))
NeverTreatedParallel{Unconditional,Exact}

julia> nevertreated([-1, 0])
Parallel trends with any never-treated group:
  Never-treated groups: -1, 0

julia> nevertreated([-1, 0]) == nevertreated(-1:0) == nevertreated(Set([-1, 0]))
true
DiffinDiffsBase.notyettreatedMethod
notyettreated(e, ecut, c::ParallelCondition, s::ParallelStrength)
notyettreated(e, ecut=e; c=Unconditional(), s=Exact())

Construct a NotYetTreatedParallel with fields set by the arguments. By default, c is set as Unconditional() and s is set as Exact(). When working with @formula, a wrapper method of notyettreated calls this method.

Examples

julia> notyettreated(5)
Parallel trends with any not-yet-treated group:
  Not-yet-treated groups: 5
  Treated since: 5

julia> typeof(notyettreated(5))
NotYetTreatedParallel{Unconditional,Exact}

julia> notyettreated([-1, 5, 6], 5)
Parallel trends with any not-yet-treated group:
  Not-yet-treated groups: -1, 5, 6
  Treated since: 5

julia> notyettreated([4, 5, 6], [4, 5, 6])
Parallel trends with any not-yet-treated group:
  Not-yet-treated groups: 4, 5, 6
  Treated since: 4, 5, 6
DiffinDiffsBase.parse_didargs!Method
parse_didargs!(args::Vector{Any}, kwargs::Dict{Symbol,Any})

Return a Dict that is suitable for being passed to valid_didargs for further processing.

Any TreatmentTerm in args is decomposed. Any collection of terms is converted to TermSet. Keys are assigned to all positional arguments based on their types. An optional name for StatsSpec can be included in args as a string. The order of positional arguments is irrelevant.

This function is required for @specset to work properly.

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.post!Method
post!(f, ::StataPostHDF, r::AbstractDIDResult; kwargs...)

Export result r for Stata module posthdf. A subset of field values from r are placed in f by setting key-value pairs, where f can be either an HDF5.Group or any object that can be indexed by strings.

Keywords

  • model::String=repr(typeof(r)): name of the model.
  • fields::Union{AbstractVector{<:Union{Symbol, Pair{String,Symbol}}}, Nothing}=nothing: additional fields to be exported; alternative names can be specified with Pairs.
  • at::Union{AbstractVector{<:Real}, Bool, Nothing}=nothing: post the at vector in Stata.
DiffinDiffsBase.rescaleFunction
rescale(r::AbstractDIDResult, scale::AbstractVector{<:Real}, subset=nothing)
rescale(r::AbstractDIDResult, by::Pair, subset=nothing)

Rescale the coefficient estimates from DID result r. The order of elements in scale must match the order of coefficients. If the length of scale is smaller than the total number of coefficient, subset must be specified with indices representing coefficients that remain after the transformation. Alternatively, if by is specified in the same way for apply, the scales can be computed based on values in treatcells(r). In this case, only treatment coefficients are transformed even if subset is not specified. See lincom for more general transformation.

DiffinDiffsBase.setpanelMethod
setpanel(data, idname, timename; step, reftype, rotation)
setpanel(id::AbstractArray, time::AbstractArray; step, reftype, rotation)

Declare a PanelStructure which is required for certain operations such as lag and diff. Unit IDs and time values can be provided either as a table containing the relevant columns or as arrays. timestep must be specified unless the time array is a ScaledArray that is returned by settime.

Arguments

  • data: a Tables.jl-compatible data table.
  • idname::Union{Symbol,Integer}: the name of the column in data that contains unit IDs.
  • timename::Union{Symbol,Integer}: the name of the column in data that contains time values.
  • id::AbstractArray: the array containing unit IDs (only needed for the alternative method).
  • time::AbstractArray: the array containing time values (only needed for the alternative method).

Keywords

  • step=nothing: the length of each time interval; try step=one(eltype(time)) if not specified.
  • reftype::Type{<:Signed}=Int32: the element type of the reference values for PanelStructure.
  • rotation=nothing: rotation groups in a rotating sampling design; use RotatingTimeValues as reference values.
Note

If the underlying data used to create the PanelStructure are modified. The changes will not be reflected in the existing instances of PanelStructure. A new instance needs to be created with setpanel.

DiffinDiffsBase.settimeFunction
settime(time::AbstractArray, step; start, stop, reftype, rotation)

Convert a column of time values to a ScaledArray for representing discretized time periods of uniform length. If rotation is specified (time values belong to multiple rotation groups), a RotatingTimeArray is returned with the time field being a ScaledArray. The returned array ensures well-defined time intervals for operations involving relative time (such as lag and diff). See also aligntime.

Arguments

  • time::AbstractArray: the array containing time values.
  • step=nothing: the length of each time interval; try step=one(eltype(time)) if not specified.

Keywords

  • start=nothing: the first element of the pool of the returned ScaledArray.
  • stop=nothing: the last element of the pool of the returned ScaledArray.
  • reftype::Type{<:Signed}=Int32: the element type of the reference values for the ScaledArray.
  • rotation=nothing: rotation groups in a rotating sampling design.
DiffinDiffsBase.subcolumnsFunction
subcolumns(data, names, rows=Colon(); nomissing=true)

Construct a VecColumnTable from data using columns specified with names over selected rows.

By default, columns are converted to drop support for missing values. When possible, resulting columns share memory with original columns.

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.treatcellsMethod
treatcells(r::AbstractDIDResult)

Return a Tables.jl-compatible tabular description of treatment coefficients in the order of coefnames (without covariates).

DiffinDiffsBase.treatindexMethod
treatindex(ntcoef::Int, I)

Extract indices referencing the treatment coefficients from I based on the total number of treatment coefficients ntcoef.

DiffinDiffsBase.treatvcovMethod
treatvcov(r::AbstractDIDResult)

Return a view of variance-covariance matrix for treatment coefficients.

DiffinDiffsBase.valid_didargsMethod
valid_didargs(args::Dict{Symbol,Any})

Return a tuple of objects that can be accepted by the constructor of StatsSpec. If no DiffinDiffsEstimator is found in args, try to select one based on other information.

This function is required for @specset to work properly.

DiffinDiffsBase.vceMethod
vce(r::AbstractDIDResult)

Return the covariance estimator used to estimate variance-covariance matrix.

ShiftedArrays.lagFunction
lag(panel::PanelStructure, v::AbstractArray, l::Integer=1; default=missing)

Return a vector of lth lagged values of v with missing values filled with default. The panel structure is respected. See also ilag! and lead.

ShiftedArrays.leadFunction
lead(panel::PanelStructure, v::AbstractArray, l::Integer=1; default=missing)

Return a vector of lth lead values of v with missing values filled with default. The panel structure is respected. See also ilead! and lag.

StatsAPI.coefMethod
coef(r::AbstractDIDResult, name::String)
coef(r::AbstractDIDResult, name::Symbol)
coef(r::AbstractDIDResult, i::Int)
coef(r::AbstractDIDResult, inds)

Retrieve a point estimate by name (as in coefnames) or integer index. Return a vector of estimates if an iterable collection of names or integers are specified.

Indexing by name requires the method coefinds(r). See also AbstractDIDResult.

StatsAPI.coefMethod
coef(r::AbstractDIDResult, bys::Pair...)

Return a vector of point estimates for treatment coefficients selected based on the specified functions that return either true or false.

Depending on the argument(s) accepted by a function f, it is specified with argument bys as either column_index => f or column_indices => f where column_index is either a Symbol or Int for a column in treatcells and column_indices is an iterable collection of such indices for multiple columns. f is applied elementwise to each specified column to obtain a BitVector for selecting coefficients. If multiple Pairs are provided, the results are combined into one BitVector through bit-wise and.

Note

This method only selects estimates for treatment coefficients. Covariates are not taken into account.

StatsAPI.coefMethod
coef(r::AbstractDIDResult)

Return the vector of point estimates for all coefficients.

StatsAPI.coefnamesMethod
coefnames(r::AbstractDIDResult)

Return a vector of coefficient names.

StatsAPI.confintMethod
confint(r::AbstractDIDResult; level::Real=0.95)

Return a confidence interval for each coefficient estimate. The returned object is of type Tuple{Vector{Float64}, Vector{Float64}} where the first vector collects the lower bounds for all intervals and the second one collects the upper bounds.

StatsAPI.dof_residualMethod
dof_residual(r::AbstractDIDResult)

Return the residual degrees of freedom.

StatsAPI.nobsMethod
nobs(r::AbstractDIDResult)

Return the number of observations (table rows) involved in estimation.

StatsAPI.responsenameMethod
responsename(r::AbstractDIDResult)

Return the name of outcome variable generated by StatsModels.coefnames. This method is an alias of outcomename.

StatsAPI.vcovFunction
vcov(r::AbstractDIDResult, name1::Union{String, Symbol}, name2::Union{String, Symbol}=name1)
vcov(r::AbstractDIDResult, i::Int, j::Int=i)
vcov(r::AbstractDIDResult, inds)

Retrieve the covariance between two coefficients by name (as in coefnames) or integer index. Return the variance if only one name or index is specified. Return a variance-covariance matrix for selected coefficients if an iterable collection of names or integers are specified.

Indexing by name requires the method coefinds(r). See also AbstractDIDResult.

StatsAPI.vcovMethod
vcov(r::AbstractDIDResult, bys::Pair...)

Return a variance-covariance matrix for treatment coefficients selected based on the specified functions that return either true or false.

Depending on the argument(s) accepted by a function f, it is specified with argument bys as either column_index => f or column_indices => f where column_index is either a Symbol or Int for a column in treatcells and column_indices is an iterable collection of such indices for multiple columns. f is applied elementwise to each specified column to obtain a BitVector for selecting coefficients. If multiple Pairs are provided, the results are combined into one BitVector through bit-wise and.

Note

This method only selects estimates for treatment coefficients. Covariates are not taken into account.

StatsAPI.vcovMethod
vcov(r::AbstractDIDResult)

Return the variance-covariance matrix for all coefficient estimates.

StatsAPI.weightsMethod
weights(r::AbstractDIDResult)

Return the column name of the weight variable. Return nothing if weights is not specified for estimation.

DiffinDiffsBase.@didMacro
@did [option option=val ...] "name" args... kwargs...

Conduct difference-in-differences estimation with the specified arguments. The order of the arguments is irrelevant.

Arguments

  • [option option=val ...]: optional settings for @did including keyword arguments passed to an instance of StatsSpec.
  • name::AbstractString: an optional name for the StatsSpec.
  • args... kwargs...: a list of arguments to be processed by parse_didargs! and valid_didargs.

Notes

When expanded outside @specset, a StatsSpec is constructed and then estimated by calling this instance. Options for [StatsSpec] can be provided in a bracket [...] as the first argument after @did with each option separated by white space. For options that take a Boolean value, specifying the name of the option is enough for setting the value to be true. By default, only a result object that is a subtype of DIDResult is returned.

When expanded inside @specset, @did informs @specset the methods for processing the arguments. Any option specified in the bracket is ignored.

Options for the behavior of @did can be provided in a bracket [...] as the first argument with each option separated by white space. For options that take a Boolean value, specifying the name of the option is enough for setting the value to be true.

The following options are available for altering the behavior of @did:

  • noproceed::Bool=false: return the constructed StatsSpec without conducting the procedure.
  • verbose::Bool=false: print the name of each step when it is called.
  • keep=nothing: names (of type Symbol) of additional objects to be returned.
  • keepall::Bool=false: return all objects generated by procedures along with arguments from the StatsSpecs.
  • pause::Int=0: break the iteration over StatsSteps after finishing the specified number of steps (for debugging).
DiffinDiffsBase.@fieldequalMacro
@fieldequal Supertype

Define a method of == for all subtypes of Supertype such that == returns true if two instances have the same field values.