AdaemmerP / lpirfs

40 stars 21 forks source link

R crashes on running example #24

Closed giannilmbd closed 2 years ago

giannilmbd commented 2 years ago

Hi, Thanks for putting this code together and making it available. I'm running R 4.2.2 on Linux Ubuntu 22.04 (kernel 15.0.52-generic). I downloaded your package from github. I ran your example (after changing rgdp.. for rgdpmad (as the original is not in the dataset any longer) and R crashed. Any clue what might be going wrong? Thanks Gianni

`jst_data<-readstata13::read.dta13(file = '../DATA/JSTdatasetR6.dta') jst_data <- jst_data %>% dplyr::filter(year <= 2013) %>% dplyr::select(country, year, everything()) data_set <- jst_data %>% mutate(stir = stir) %>% mutate(mortgdp = 100*(tmort/gdp)) %>% mutate(hpreal = hpnom/cpi) %>% group_by(country) %>% mutate(hpreal = hpreal/hpreal[year==1990][1]) %>% mutate(lhpreal = log(hpreal)) %>%

              mutate(lhpy     = lhpreal - log(rgdpmad))        %>%
            mutate(lhpy     = lhpy - lhpy[year == 1990][1]) %>%
            mutate(lhpreal  = 100*lhpreal)                  %>%
            mutate(lhpy     = 100*lhpy)                     %>%
            ungroup()                                       %>%

            mutate(lrgdp    = 100*log(rgdpmad))              %>%
            mutate(lcpi     = 100*log(cpi))                     %>%
            mutate(lriy     = 100*log(iy*rgdpmad))           %>%
            mutate(cay      = 100*(ca/gdp))                 %>%
            mutate(tnmort   = tloans - tmort)               %>%
            mutate(nmortgdp = 100*(tnmort/gdp))             %>%
            dplyr::select(country, year, mortgdp, stir, ltrate,
                          lhpy, lrgdp, lcpi, lriy, cay, nmortgdp)

data_sample <- seq(1870, 2013)[!(seq(1870, 2016) %in% c(seq(1914, 1918), seq(1939, 1947)))] results_panel <- lpirfs::lp_lin_panel(data_set = data_set, data_sample = data_sample, endog_data = "mortgdp", cumul_mult = TRUE,

                            shock             = "stir",
                            diff_shock        = TRUE,
                            panel_model       = "within",
                            panel_effect      = "individual",
                            robust_cov        = "vcovSCC",

                            c_exog_data       = "cay",
                            l_exog_data       = "cay",
                            lags_exog_data    = 2,
                            c_fd_exog_data    = colnames(data_set)[c(seq(4,9),11)],
                            l_fd_exog_data    = colnames(data_set)[c(seq(3,9),11)],
                            lags_fd_exog_data = 2,

                            confint           = 1.67,
                            hor               = 5)`
AdaemmerP commented 2 years ago

I ran your code on my computer using Ubuntu 22.04 (kernel 15.0.52-generic) and R 4.2.1 as well as R 4.2.2 and it did not crash. Do you get any error message?

giannilmbd commented 2 years ago

Thanks Philipp, I think the crash is due to dates being of class Date and not numeric. The crash was hard and without messages. Once turned dates into numeric, the code works well.

Thanks for your help

On Thu, 3 Nov 2022 at 12:34, Philipp Adämmer @.***> wrote:

I ran your code on my computer using Ubuntu 22.04 (kernel 15.0.52-generic) and R 4.2.1 as well as R 4.2.2 and it did not crash. Do you get any error message?

— Reply to this email directly, view it on GitHub https://github.com/AdaemmerP/lpirfs/issues/24#issuecomment-1301969720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLXB3ZK5HZBYSPZRLO3EWLWGOPK3ANCNFSM6AAAAAARV6ARVA . You are receiving this because you authored the thread.Message ID: @.***>

-- Giovanni Lombardo Bank for International Settlements Basel - CH www.giovannilombardo.ch @.***

AdaemmerP commented 2 years ago

Great, happy to hear that and happy to help! Please cite the paper when using the package for scientific publications: https://journal.r-project.org/archive/2019/RJ-2019-052/index.html