AdaemmerP / lpirfs

40 stars 21 forks source link

Automatic lag selection #22

Closed mfeldk closed 2 years ago

mfeldk commented 2 years ago

Hi, seems that the automatic lag selection does not work. The example code with your example data:

g_data <- ag_data sample_start <- 7 sample_end <- dim(ag_data)[1]

Endogenous data

endog_data <- ag_data[sample_start:sample_end,3:5] shock <- ag_data[sample_start:sample_end, 3]

Estimate linear model

results_lin_iv <- lp_lin_iv(endog_data, max_lags = 12, lags_criterion="AIC", shock = shock, trend = 0, confint = 1.96, hor = 20)

Gives the error Error in if (is.nan(lags_endog_lin) & !is.character(lags_criterion)) { : argument is of length zero

Can you point me to a solution? Regards, Martin

AdaemmerP commented 2 years ago

In that case you have to set "lags_endog_lin = NaN":

results_lin_iv <- lp_lin_iv(endog_data,
                            max_lags       = 12,
                            lags_endog_lin = NaN,
                            lags_criterion = "AIC",
                            shock          = shock,
                            trend          = 0,
                            confint        = 1.96,
                            hor            = 20)

Does that work?

mfeldk commented 2 years ago

yes, works. thank you!