# lp_lin: Compute linear impulse responses In lpirfs: Local Projections Impulse Response Functions

## Description

Compute linear impulse responses with local projections by Jordà (2005).

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```lp_lin( endog_data, lags_endog_lin = NULL, lags_criterion = NaN, max_lags = NaN, trend = NULL, shock_type = NULL, confint = NULL, use_nw = TRUE, nw_lag = NULL, nw_prewhite = FALSE, adjust_se = FALSE, hor = NULL, exog_data = NULL, lags_exog = NULL, contemp_data = NULL, num_cores = 1 ) ```

## Arguments

 `endog_data` A data.frame, containing the endogenous variables for the VAR. The Cholesky decomposition is based on the column order. `lags_endog_lin` NaN or integer. NaN if lag length criterion is used. Integer for number of lags for endog_data. `lags_criterion` NaN or character. NaN (default) means that the number of lags has to be given at lags_endog_lin. The character specifies the lag length criterion ('AICc', 'AIC' or 'BIC'). `max_lags` NaN or integer. Maximum number of lags if lags_criterion is given. NaN (default) otherwise. `trend` Integer. No trend = 0 , include trend = 1, include trend and quadratic trend = 2. `shock_type` Integer. Standard deviation shock = 0, unit shock = 1. `confint` Double. Width of confidence bands. 68% = 1; 90% = 1.65; 95% = 1.96. `use_nw` Boolean. Use Newey-West (1987) standard errors for impulse responses? TRUE (default) or FALSE. `nw_lag` Integer. Specifies the maximum lag with positive weight for the Newey-West estimator. If set to NULL (default), the lag increases with with the number of horizon. `nw_prewhite` Boolean. Should the estimators be pre-whitened? TRUE or FALSE (default). `adjust_se` Boolen. Should a finite sample adjsutment be made to the covariance matrix estimators? TRUE or FALSE (default). `hor` Integer. Number of horizons for impulse responses. `exog_data` A data.frame, containing exogenous variables for the VAR. The row length has to be the same as endog_data. Lag lengths for exogenous variables have to be given and will no be determined via a lag length criterion. `lags_exog` Integer. Number of lags for the exogenous variables. `contemp_data` A data.frame, containing exogenous data with contemporaneous impact. The row length has to be the same as endog_data. `num_cores` NULL or Integer. The number of cores to use for the estimation. If NULL, the function will use the maximum number of cores minus one.

## Value

A list containing:

 `irf_lin_mean` A three 3D array, containing all impulse responses for all endogenous variables. The last dimension denotes the shock variable. The row in each matrix gives the responses of the ith variable, ordered as in endog_data. The columns denote the horizons. For example, if results_lin contains the list with results, results_lin\$irf_lin_mean[, , 1] returns a KXH matrix, where K is the number of variables and H the number of horizons. '1' is the shock variable, corresponding to the first variable in endog_data. `irf_lin_low` A three 3D array containing all lower confidence bands of the responses, based on robust standard errors by Newey and West (1987). Properties are equal to irf_lin_mean. `irf_lin_up` A three 3D array containing all upper confidence bands of the responses, based on robust standard errors by Newey and West (1987). Properties are equal to irf_lin_mean. `diagnostic_list` A list OLS diagnostics. To see everything you can simply use summary() or results\$diagnostic_list. The first entry the shock variable. The rows of each shown matrix then denotes the endogenous variable that reacts to the shock. `specs` A list with properties of endog_data for the plot function. It also contains lagged data (y_lin and x_lin) used for the irf estimations, and the selected lag lengths when an information criterion has been used.

## References

Akaike, H. (1974). "A new look at the statistical model identification", IEEE Transactions on Automatic Control, 19 (6): 716–723.

Hurvich, C. M., and Tsai, C.-L. (1989), "Regression and time series model selection in small samples", Biometrika, 76(2): 297–307

Jordà, Ò. (2005). "Estimation and Inference of Impulse Responses by Local Projections." American Economic Review, 95 (1): 161-182.

Newey, W.K., and West, K.D. (1987). “A Simple, Positive-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix.” Econometrica, 55: 703–708.

Schwarz, Gideon E. (1978). "Estimating the dimension of a model", Annals of Statistics, 6 (2): 461–464.

 ``` 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69``` ``` ## Example without exogenous variables # Load package library(lpirfs) # Load (endogenous) data endog_data <- interest_rules_var_data # Estimate linear model results_lin <- lp_lin(endog_data, lags_endog_lin = 4, trend = 0, shock_type = 1, confint = 1.96, hor = 12) # Show all impule responses # Compare with Figure 5 in Jordà (2005) plot(results_lin) # Make individual plots linear_plots <- plot_lin(results_lin) # Show single plots # * The first element of 'linear_plots' shows the response of the first # variable (GDP_gap) to a shock in the first variable (GDP_gap). # * The second element of 'linear_plots' shows the response of the first # variable (GDP_gap) to a shock in the second variable (inflation). # * ... linear_plots[[1]] linear_plots[[2]] # Show diagnostics. The first element correponds to the first shock variable. summary(results_lin) ## Example with exogenous variables ## # Load (endogenous) data endog_data <- interest_rules_var_data # Create exogenous data and data with contemporaneous impact (for illustration purposes only) exog_data <- endog_data\$GDP_gap*endog_data\$Infl*endog_data\$FF + rnorm(dim(endog_data)[1]) contemp_data <- endog_data\$GDP_gap*endog_data\$Infl*endog_data\$FF + rnorm(dim(endog_data)[1]) # Exogenous data has to be a data.frame exog_data <- data.frame(xx = exog_data ) contemp_data <- data.frame(cc = contemp_data) # Estimate linear model results_lin <- lp_lin(endog_data, lags_endog_lin = 4, trend = 0, shock_type = 1, confint = 1.96, hor = 12, exog_data = exog_data, lags_exog = 4, contemp_data = contemp_data) # Show all impulse responses plot(results_lin) # Show diagnostics. The first element correponds to the first shock variable. summary(results_lin) ```