Im using a for loop to perform some estimations with the nardl()
function. My specific function is the following:
#Estimacion de la boyanza de corto plazo por sector
Boyanza_Corto_Plazo <- function(i) {
Sector_elegido <- Series_por_sector[i] #Estimar cada serie por separado
Sector_elegido <- as.data.frame(Sector_elegido)
#y <- Sector_elegido[,2]
#x <- Sector_elegido[,1]
#modelo_correccion_errores <- aTSA::ecm(y,x)
ardl <- nardl(Sector_elegido[,2]~Sector_elegido[,1],data = Sector_elegido,maxlags = TRUE)
#Resultados Modelo de Correciones de Errores
#Resultados_ecm <- as.data.frame(modelo_correccion_errores$coefficients)
#Resultados Modelo Autorregresivo de Rezagos Distribuidos
ardl$lres
}
Resultados_Boyanza_CortoPlazo <- lapply(1:length(serie_unica), Boyanza_Corto_Plazo) %>%
setNames(serie_unica)
Where Series_por_sector
is a list formed by time series.
The problem is that once I perform this, i get the same result for the fifteen values. I performed the code one by one and it has different values for each result. Is there an error in the for loop or the function?
Data
Series_por_sector <- list(`Administracion Publica` = structure(c(23.1088620514831,
23.2109063202046, 23.2769873592992, 23.3605352985273, 23.4519346734195,
23.483205532437, 23.7591278454179, 23.6850360808979, 23.683115488847,
23.742078603493, 23.7663243593632, 23.764967369018, 23.7364563768631,
23.7599662090129, 23.7496509758095, 23.7686965597259, 23.7977667134767,
23.8207387874707, 23.8654579645418, 23.8245489693678, 23.9265214407142,
23.9145837058818, 23.9142594395867, 23.9950372209453, 23.962962969242,
24.0353280983239, 24.0451662222755, 24.2065811733021, 24.2090422600631,
24.164897354507, 24.2107239155159, 24.2013823343176, 24.1945118651099,
24.2386054601983, 24.1253600441108, 24.1634700277298, 24.24710422059,
24.2640569230369, 24.2191827178458, 24.2636917589338, 24.322742284412,
24.3485370356597, 24.389637008929, 24.4114167612282, 24.4230970285861,
24.4845569534887, 24.4824708646545, 24.5654465306632, 16.2690985732647,
16.4386018734529, 16.851630812087, 16.6414972640505, 17.1058597508038,
17.014281852952, 17.1191750738733, 16.8608600925248, 16.9304970555101,
16.6136770217261, 16.7599831928413, 16.4540571915749, 16.7552091555068,
16.8100146613935, 16.9753886743241, 17.2559883430648, 17.1842102120934,
17.3815201756025, 17.3148608548369, 17.5596787855012, 17.5384238342067,
17.6258161301485, 17.367905481101, 17.2726943078947, 17.2030548088381,
17.3321154111439, 17.5589703318828, 17.6671996562904, 18.0414455740657,
17.9911990393175, 17.9793197549134, 18.0986395501199, 17.9982500487969,
18.2293428092301, 18.416988766537, 18.9520128550431, 18.5498461288987,
18.5073800917836, 18.3124545933365, 18.7412643661601, 18.5659965557844,
18.8370796958012, 18.9838794236317, 18.799868193603, 18.9893923810632,
19.0239372373528, 18.7336946461114, 18.792862397096), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")), Agropecuaria = structure(c(23.8974172022309,
23.8426522293242, 23.8786025678373, 23.9234443277368, 23.955785063984,
23.9488055976204, 24.0194464814519, 24.0355500701664, 24.0205607574373,
23.9765003819766, 23.9863872713793, 24.0171893839021, 24.1108105209366,
24.1242478251806, 24.0974361919034, 24.1441462607396, 24.1319142785708,
24.1571013126376, 24.2096399220679, 24.1363606441852, 24.1912397024969,
24.2249078202319, 24.1393775469111, 24.1932906271901, 24.2347461668014,
24.292215799013, 24.2663996098303, 24.2679583510404, 24.3051016718751,
24.3260743926178, 24.3605254155406, 24.4282569129793, 24.4556975208826,
24.4387907390123, 24.5062189765647, 24.6019406593183, 24.5677944247836,
24.5829066028276, 24.6441787260105, 24.5722032035857, 24.5747298230972,
24.6429122022835, 24.6871883460115, 24.6818910199581, 24.6755650563727,
24.7191476175315, 24.7758153911166, 24.7035539340166, 17.3520147511469,
17.5019693803128, 17.7427308725145, 17.5728914152593, 17.6770013267762,
17.6530027742057, 17.6340294870891, 17.4432563458735, 17.4416872398418,
17.6295775122599, 17.651375975813, 17.4408807343564, 17.5561240496743,
17.6490863243478, 17.7624089659032, 18.1616128908896, 17.8126634086638,
17.5209304636998, 17.5056551305215, 17.6151152309561, 17.629944161796,
17.8442028876549, 17.7081428718954, 17.5943688159008, 17.6346589843816,
17.6707656285536, 17.878255754036, 17.9475483858192, 17.9138103344089,
18.2280489203447, 18.2779985993668, 18.5045059287446, 18.3055466958494,
18.0813929061191, 18.1066069724926, 18.1035991705582, 18.2351041279044,
18.1207747946839, 18.140343870442, 18.3064405036347, 18.2525819596875,
18.2556394115664, 18.1351550728756, 18.1781952679869, 18.684236705932,
18.7754363617656, 18.6688183305532, 18.9307958795054), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")), `Alquiler de Viviendas` = structure(c(24.0006751666943,
24.0340592554054, 24.0680238113269, 24.1189254582254, 24.1429088813474,
24.1777417773996, 24.2246656047735, 24.251733128356, 24.2502587974969,
24.2995059086229, 24.3818266633241, 24.4274377756904, 24.4460131221639,
24.4669868297722, 24.4935610827344, 24.5558404630517, 24.6137504075591,
24.6672683318767, 24.7094318300949, 24.733862789062, 24.7217146756303,
24.7250026668479, 24.7143006888566, 24.7402821079578, 24.7546300561241,
24.767680402686, 24.7843137141875, 24.808853430029, 24.8507316944205,
24.8588586737822, 24.865040423614, 24.8639260844803, 24.8913005324989,
24.9071142444601, 24.9198059636058, 24.9225026283004, 24.9570861190926,
24.9757496061167, 24.9865754608314, 24.9922466239614, 25.0215061302973,
25.0401591698257, 25.055364085766, 25.0577641891848, 25.0891343758379,
25.1093228397352, 25.1180411403536, 25.1197533984494, 18.9593078212553,
19.3008332475991, 19.2310716049415, 19.2088960072736, 19.2964902687309,
19.3163205064635, 19.3690846090817, 19.2813216073373, 19.338612494098,
19.3238357321123, 19.3096978069183, 19.3218745761893, 19.3359647313599,
19.3595512037955, 19.4432337502825, 19.5419292850372, 19.367867853648,
19.4792554617571, 19.4744789385823, 19.4970904331532, 19.4864988932459,
19.461090804926, 19.5023798309416, 19.5724897897347, 19.6788361170831,
19.7895722836087, 19.7660725132758, 19.8233639156982, 19.860259893191,
19.966495921088, 19.9860812548669, 19.9990319153442, 20.0326109808829,
20.0452911486641, 20.1108100946792, 20.1520982005704, 20.251063167808,
20.191144945087, 20.1876101017726, 20.2377436916409, 20.2276964297304,
20.2915818876374, 20.2896334296863, 20.3486369626646, 20.4005251275962,
20.3741955381774, 20.4933058962091, 20.5219375235474), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")), Comercio = structure(c(24.1370434718447,
24.1474679560082, 24.247774315585, 24.3309113902029, 24.3783871731216,
24.4445666853879, 24.4808566103939, 24.3739825549957, 24.3422311994027,
24.3707336209133, 24.4088239471052, 24.4582189848896, 24.5749890813745,
24.629195568656, 24.6455654186535, 24.6729956287059, 24.7088855755689,
24.7333803859132, 24.7201636721202, 24.7551669596583, 24.8092172605393,
24.8061162844105, 24.8168094913596, 24.8323326931589, 24.8272348481957,
24.8336101639175, 24.8712888927901, 24.8930736664768, 24.9176867747641,
24.9777325188736, 25.0056963886149, 25.0642368960481, 25.1093674771005,
25.0869568996516, 25.1678570679605, 25.2154060650998, 25.2128877023623,
25.2429075653786, 25.281613916562, 25.3005161445634, 25.2961991109808,
25.3072650677793, 25.2973309550997, 25.3617282270681, 25.3865019926842,
25.4163177121506, 25.4190764412604, 25.4411634800277, 21.2983035898428,
21.3570067572794, 21.4452936588011, 21.4237851772619, 21.4273073318266,
21.4945534576367, 21.4258382239739, 21.3295361689986, 21.3045228064109,
21.3944020927061, 21.4842073973378, 21.4389384907488, 21.4956072256246,
21.3930354066646, 21.3278405349757, 21.5128955832531, 21.4507435697624,
21.5250876204212, 21.4066744817499, 21.4443117036001, 21.6059428597013,
21.6369336788754, 21.5904970674634, 21.6635309673871, 21.8297886435693,
21.8465397001402, 21.9068560451084, 21.953016327191, 22.0205414069325,
21.9367168184625, 21.9770088938013, 22.0085679027535, 22.0860223086015,
22.060262279998, 22.1844033814521, 22.1960941239081, 22.1002613229137,
22.1831252090577, 22.269441531446, 22.2390935138727, 22.1294723280912,
22.2031216834464, 22.2797664344226, 22.3571514107923, 22.3820705584665,
22.4259895425348, 22.4991828106128, 22.5097930497936), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")), Comunicaciones = structure(c(22.7159215016701,
22.7442934923426, 22.8156289557376, 22.8103180688631, 22.9079280521587,
22.8651731130763, 22.8185625327301, 22.7879980426273, 22.8257259562352,
22.9543244956688, 22.9024934066312, 22.9249025428433, 22.988677715386,
23.0101125568586, 22.9546422949912, 22.9850867549534, 22.9651084826172,
22.9540511508368, 22.9108721846524, 22.9509357016076, 22.8808470019626,
22.8471037021794, 22.8221045329777, 22.847135573551, 22.8141938440927,
22.8435180027461, 22.9127566686255, 22.8493302959942, 22.8041794119784,
22.8202482099194, 22.8161997967681, 22.7727440025612, 22.815257442878,
22.8298190159059, 22.8664428656122, 22.8862096742561, 22.8553284792427,
22.878577485562, 22.8968137208948, 22.9241070538481, 22.9144722667933,
22.8880620951397, 22.9420612614645, 22.9834423350717, 23.0095123223225,
22.9597572724236, 23.0723326115794, 23.1097434102164, 20.8239716869769,
20.5226542439175, 20.6026890686682, 20.76310324137, 20.9131971943851,
20.7205251172263, 20.5774355857312, 20.7136250593865, 20.4564302498454,
20.7767470846672, 20.9099449005612, 20.951959385823, 20.9848515489911,
20.9900123676892, 20.9390425878003, 20.8699224312633, 20.9023061288989,
21.0558234020519, 21.015551221213, 20.9845630460342, 21.0705504536071,
21.1018779848056, 21.1459912615211, 21.0792073320455, 21.2352066231257,
21.2852187072191, 21.3713592385595, 21.2529499988486, 21.4376334474516,
21.4275513591843, 21.4684247354223, 21.5283291824696, 21.4079744851135,
21.3797841890375, 21.4806534896227, 21.4629795746998, 21.5305509488717,
21.5253402007029, 21.5288601216958, 21.5186845853155, 21.5536213729911,
21.4778607621153, 21.5269248692107, 21.6565995758113, 21.5436387178381,
21.5233578775461, 21.6342874994564, 21.5566078595888), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")), Construccion = structure(c(24.3104512383546,
24.3394290212942, 24.3685369226656, 24.4001487592087, 24.4313358764547,
24.5637013122111, 24.628809834211, 24.4138986476927, 24.5081816554895,
24.487818690176, 24.5241059114576, 24.4798591263034, 24.6118953722024,
24.6117736694609, 24.6459997019144, 24.6616526205874, 24.7972745337092,
24.7026781507544, 24.7538879069839, 24.7702794155517, 24.8630224317717,
24.7654205720821, 24.7686333334311, 24.7977896117515, 24.8267493068813,
24.8903323322539, 24.9341888192851, 24.9938126923127, 25.0505717195684,
25.0409295327285, 25.0695668362172, 25.1536776503307, 25.0496999985082,
25.1099439688764, 25.1478211910891, 25.2037124928483, 25.1047936889341,
25.1700961746316, 25.0649422946338, 25.1924468939817, 25.2013639833252,
25.2708112626769, 25.3429207496999, 25.4601548137581, 25.3718269603702,
25.5022070811831, 25.5200212858805, 25.6406421545549, 19.1311784876827,
19.3619706519596, 19.3628787073326, 19.3423206272171, 19.4330346384083,
19.5156278154174, 19.5729825269357, 19.4363731729595, 19.3711685254248,
19.3275457471445, 19.3891653130203, 19.3309563793927, 19.480197560506,
19.5915941730223, 19.620493537738, 19.799001695147, 19.8551635762407,
19.8323528497659, 19.8221845538554, 19.9675185991679, 19.9382260968915,
19.6148322148458, 19.7224392314754, 19.6673232367288, 19.7318790786149,
19.8242729948508, 19.8528377245517, 19.8665021028161, 19.9548882721544,
19.9685129522984, 20.116318982605, 20.2142748977724, 20.1937649557145,
20.2549289856348, 20.3206791254058, 20.2985256718267, 20.2899519583351,
20.4189483025824, 20.2901939953295, 20.3633307990819, 20.4126419877815,
20.5255910482695, 20.4743999783096, 20.5958991005088, 20.5358549516528,
20.6569150364701, 20.5858968756658, 20.7941066075041), .Dim = c(48L,
2L), .Dimnames = list(NULL, c("lpib", "lrecaudacion")), .Tsp = c(2007,
2018.75, 4), class = c("mts", "ts", "matrix")))