Thats a nice solution.. however, we are not able to recognise which variable the test is for. I would have loved to have it printed too. i did something like this
packages<-c("tidyverse","urca","rlist")
sapply(packages,library,character.only=T)
#> $tidyverse
#> [1] "forcats" "stringr" "dplyr" "purrr" "readr" "tidyr"
#> [7] "tibble" "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
#> [13] "utils" "datasets" "methods" "base"
#>
#> $urca
#> [1] "urca" "forcats" "stringr" "dplyr" "purrr" "readr"
#> [7] "tidyr" "tibble" "ggplot2" "tidyverse" "stats" "graphics"
#> [13] "grDevices" "utils" "datasets" "methods" "base"
#>
#> $rlist
#> [1] "rlist" "urca" "forcats" "stringr" "dplyr" "purrr"
#> [7] "readr" "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
#> [13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
data_diff<-tibble::tribble(
~diff_ln_CONS,~diff_ln_INC,~diff_ln_INV,
0.0023784463, 0.0049896035,-0.001073375 ,
0.0050201180, 0.0068329593, 0.006335689 ,
0.0052142383, 0.0026419800, 0.007089079 ,
0.0039655621, 0.0051378076, 0.017789113 ,
-0.0003559097, 0.0034247231,-0.008178185 ,
0.0072904740, 0.0003071246, 0.004595634
)
MY_LIST=apply(data[,5:7],2,function(x){
return(
list(
ur.df(x, type = "drift",selectlags = c("BIC")),
ur.df(x, type = "trend",selectlags = c("BIC")),
ur.df(x, type = "none",selectlags = c("BIC")),
summary(ur.pp(x,type = "Z-tau",model = "constant")),
summary(ur.pp(x,type = "Z-tau",model = "trend"))
)
)
})
#> Error in data[, 5:7]: object of type 'closure' is not subsettable
rand<-unlist(MY_LIST)
#> Error in unlist(MY_LIST): object 'MY_LIST' not found
nb<-rand %>% map_df(.,~data.table("Test Statistic"=round(.x@teststat,3),model=.x@model,
test=.x@test.name),.id="Variable")
#> Error in eval(lhs, parent, parent): object 'rand' not found
nb_crit<-rand %>% map_df(.,~data.table(crit_val=.x@cval,
model=.x@model,
test=.x@test.name),.id="Variable")
#> Error in eval(lhs, parent, parent): object 'rand' not found
Created on 2020-08-16 by the reprex package (v0.3.0)
the nb and nb_crit are the results i want. I coud'nt make it more appealing though. The issue is in nb_crit, it is not known for which statistic is the critical value. I
Thanks and regards