estimate_t0 {ArCo}R Documentation

Estimates the intervention time on a given treated unit

Description

Estimates the intervention time on a given treated unit based on any model supplied by the user.

Usage

estimate_t0(data, fn = NULL, p.fn = NULL, start = 0.4, end = 0.9,
  treated.unit = 1, lag = 0, Xreg = NULL, ...)

Arguments

data

A list of matrixes or data frames of length q. Each matrix is T X n and it contains observations of a single variable for all units and all periods of time. Even in the case of a single variable (q=1), the matrix must be inside a list.

fn

The function used to estimate the first stage model. This function must receive only two arguments in the following order: X (independent variables), y (dependent variable). If the model requires additional arguments they must be supplied inside the function fn. If not supplied the default is the lm function.

p.fn

The forecasting function used to estimate the counterfactual using the first stage model (normally a predict funtion). This function also must receive only two arguments in the following order: model (model estimated in the first stage), newdata (out of sample data to estimate the second stage). If the prediction requires additional arguments they must be supplied inside the function p.fn.

start

Initial value of \lambda_0 to be tested.

end

Final value of \lambda_0 to be tested.

treated.unit

Single number indicating the unit where the intervention took place.

lag

Number of lags in the first stage model. Default is 0, i.e. only contemporaneous variables are used.

Xreg

Exogenous controls.

...

Additional arguments used in the function fn.

Details

This description may be useful to clarify the notation and understand how the arguments must be supplied to the functions.

Value

A list with the following items:

t0

Estimated t0.

delta.norm

The norm of the delta corresponding to t0.

call

The matched call.

See Also

fitArCo

Examples

#############################
## === Example for q=1 === ##
#############################
data(data.q1) 
# = First unit was treated on t=51 by adding
# a constant equal to one standard deviation.

data=list(data.q1) # = Even if q=1 the data must be in a list

## == Fitting the ArCo using linear regression == ##

# = creating fn and p.fn function = #
fn=function(X,y){
    return(lm(y~X))
}
p.fn=function(model,newdata){
    b=coef(model)
    return(cbind(1,newdata)%*%b)
}

t0a=estimate_t0(data = data,fn = fn, p.fn = p.fn, treated.unit = 1 )


#############################
## === Example for q=2 === ##
#############################

# = First unit was treated on t=51 by adding constants of one standard deviation.
# for the first and second variables
data(data.q2) # data is already a list


t0b=estimate_t0(data = data.q2,fn = fn, p.fn = p.fn, treated.unit = 1, start=0.4)

[Package ArCo version 0.3-1 Index]