Description Usage Arguments Details Value See Also Examples

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

1 2 |

`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 |

`end` |
Final value of |

`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. |

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

units: Each unit is indexed by a number between

*1,…,n*. They are for exemple: countries, states, municipalities, firms, etc.Variables: For each unit and for every time period

*t=1,…,T*we observe*q_i ≥ 1*variables. They are for example: GDP, inflation, sales, etc.Intervention: The intervention took place only in the treated unit at time

*t_0=λ_0*T*, where*λ_0*is in (0,1).

A list with the following items:

`t0` |
Estimated t0. |

`delta.norm` |
The norm of the delta corresponding to t0. |

`call` |
The matched call. |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ```
#############################
## === 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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.