Bootstrap confidence intervals of cointegration regression

Dear All,

Please I have estimated a regression model using FMOLS and DOLS regression models and I need to calculate the bootstrap confidence intervals for the regression coefficient. I am fairly new in R and struggling with the "boot" package in R

Below is my code for DOLS model and FMOLS. I used the "cointreg" package in R

library(cointReg)

DOLS <- cointRegD(Final_data_c$ham_exp, Final_data_c$ham_rev, n.lead = 1, n.lag = 1,
kmax = "k4", info.crit = "AIC", demeaning = FALSE,
check = TRUE) # Dynmic OLS

FMOLS <- cointRegFM(ham_exp, ham_rev, demeaning = "false") # Fully modified OLS

Below is the data. I would appreciate your help please

data_aya.pdf (227.5 KB)

Thank you

Hi @Benny.owusuk ,

Sharing your data as a PDF does not make it easy for anyone to use your data in helping to answer your question. It is better if you can have your data loaded in R and then call:

dput(Final_data_c)

And then copying and pasting everything that function returns and pasting it here inside code brackets (three opening and closing back-ticks (`).

1 Like

I have experience using the cointReg package and I can probably help you. However, as pointed out by @Benny.owusuk, it would be better to share your data in a more user-friendly way.

1 Like

Please see below data after calling

("structure(list(Country = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 8L), .Label = c("CzechRepublic", "Estonia", "Hungary",
"Latvia", "Lithuania", "Poland", "SlovakRepublic", "Slovenia"
), class = "factor"), Year = structure(c(1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
1L), .Label = c("1998", "1999", "2000", "2001", "2002", "2003",
"2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019"
), class = "factor"), ham_exp = c(40.77598591, 42.46806167, 42.46167976,
42.32561935, 42.32929629, 42.80848971, 42.76903454, 43.33579847,
41.45862483, 42.40266724, 42.27326998, 42.24478127, 42.44815649,
43.02552192, 42.3943724, 42.40041881, 42.72471971, 42.17953612,
42.42813178, 42.31616525, 42.04044862, 42.25521988, 37.89123874,
37.64027451, 37.84763634, 37.99463027, 37.60662669, 37.39252184,
37.46564496, 37.38932771, 37.27510814, 37.22490779, 37.18912498,
37.21607256, 37.82824471, 38.59027311, 38.09874335, 37.68990227,
37.83860188, 37.78739471, 37.70444381, 37.87742255, 37.93343263,
37.92342644, 50.1557514, 49.2472858, 49.17547738, 49.13849996,
48.61112771, 48.3139609, 48.80366431, 49.18493771, 48.82254094,
48.85890821, 49.23633247, 49.36885211, 48.96398728, 49.02426083,
49.14298794, 48.91222162, 48.93891535, 49.04923387, 49.19907165,
49.26554986, 48.86363847, 48.24979425, 37.50713175, 37.45523669,
38.50306125, 38.63158684, 36.56326589, 36.8137813, 37.63475615,
37.01901347, 37.8522304, 37.36110579, 38.11966667, 36.92585807,
38.71673367, 39.90725115, 38.25641265, 36.3239621, 36.96129909,
37.59899111, 37.75708631, 37.65596303, 37.30102795, 38.00757865,
37.2328368, 43.25505525, 35.52251685, 37.63610017, 37.03055482,
36.23902372, 35.91916304, 35.66884007, 36.30713947, 36.16148981,
36.2650684, 36.673331, 37.83352712, 40.35183292, 37.39357436,
38.10805341, 35.0013435, 36.2995691, 36.07809282, 36.46610422,
35.92389617, 35.67288697, 45.9395045, 44.00473243, 43.70559638,
43.34130147, 42.87109069, 44.02000932, 43.91859039, 44.00844091,
43.18558444, 43.63574856, 43.64050092, 43.0739205, 43.62936295,
43.80565767, 44.07172579, 43.28717105, 43.11796317, 43.12681613,
43.08222597, 42.84685984, 42.71667021, 42.8145267, 46.07785543,
45.63039427, 44.07559478, 44.18541726, 45.87251546, 44.60266494,
43.39538804, 42.01199319, 40.48397924, 40.57458113, 40.62451608,
39.79615353, 39.55899787, 41.71928948, 42.34485439, 41.76553533,
41.50637393, 41.79304026, 42.291355, 43.14340443, 42.70389088,
41.86520509, 45.78240658), ham_rev = c(39.40013666, 39.56562783,
39.17461297, 39.42667523, 38.96432458, 39.19979708, 39.51097927,
41.22521413, 39.86721827, 39.6600092, 39.67238215, 39.92760768,
39.43198558, 39.53874875, 39.81674815, 40.19754491, 40.20120042,
40.54112549, 40.01398715, 40.42684339, 39.98503217, 40.16474412,
38.2086722, 38.09041216, 37.99680757, 37.64169656, 37.41567296,
37.15736696, 37.28765012, 37.48235246, 37.44735715, 37.10997649,
37.27818323, 37.42913988, 37.49252851, 38.79998833, 38.6967504,
38.05299242, 37.99452417, 37.97270356, 37.92454761, 38.14005286,
38.14893741, 38.0396887, 45.38071815, 43.76411969, 43.84358779,
44.21413202, 44.50570743, 43.72080148, 43.2366862, 43.30060159,
43.51914227, 43.12599615, 43.52036863, 45.15750925, 44.73913985,
45.29522223, 44.36684131, 44.17892412, 46.17212272, 45.94663671,
45.76903332, 46.52792587, 44.24536286, 44.33340452, 35.77247752,
36.70386037, 37.25162034, 35.76391243, 33.86903671, 33.68786816,
34.46843174, 33.84290453, 35.63749849, 34.91156215, 36.36863776,
33.83198975, 34.73253168, 35.98008849, 36.85713677, 35.45425072,
36.28637655, 35.86348134, 35.95841977, 35.9832732, 36.24501281,
36.58657611, 34.74682091, 38.03032551, 34.44733356, 34.62312114,
33.51001765, 32.81744493, 34.38478332, 33.91749703, 34.78754386,
35.21754383, 34.74875746, 34.85123184, 35.01036667, 35.10208685,
34.37283095, 33.34774052, 34.16048559, 34.45671806, 35.32158449,
35.05742502, 34.30953512, 34.05683745, 41.06982713, 40.84224792,
40.21196709, 40.08259471, 39.82600652, 39.69335246, 39.83114817,
39.77365558, 39.55726237, 39.6430936, 39.8793838, 39.95681237,
39.9012855, 39.51331528, 39.3345007, 39.48332912, 39.55402523,
39.48403258, 39.4544671, 39.52312956, 39.51621985, 39.60314757,
41.14453549, 40.60544034, 39.15260607, 39.86992157, 39.2139927,
37.51567243, 37.27684096, 37.53391565, 36.02053292, 37.59162829,
35.79751791, 35.39308141, 35.76225474, 37.35165575, 35.50322675,
37.94165368, 36.99597252, 39.66252343, 39.61078336, 42.05249876,
38.67228303, 39.74640741, 44.1873312)), row.names = c("CzechRepublic-1998",
"CzechRepublic-1999", "CzechRepublic-2000", "CzechRepublic-2001",
"CzechRepublic-2002", "CzechRepublic-2003", "CzechRepublic-2004",
"CzechRepublic-2005", "CzechRepublic-2006", "CzechRepublic-2007",
"CzechRepublic-2008", "CzechRepublic-2009", "CzechRepublic-2010",
"CzechRepublic-2011", "CzechRepublic-2012", "CzechRepublic-2013",
"CzechRepublic-2014", "CzechRepublic-2015", "CzechRepublic-2016",
"CzechRepublic-2017", "CzechRepublic-2018", "CzechRepublic-2019",
"Estonia-1998", "Estonia-1999", "Estonia-2000", "Estonia-2001",
"Estonia-2002", "Estonia-2003", "Estonia-2004", "Estonia-2005",
"Estonia-2006", "Estonia-2007", "Estonia-2008", "Estonia-2009",
"Estonia-2010", "Estonia-2011", "Estonia-2012", "Estonia-2013",
"Estonia-2014", "Estonia-2015", "Estonia-2016", "Estonia-2017",
"Estonia-2018", "Estonia-2019", "Hungary-1998", "Hungary-1999",
"Hungary-2000", "Hungary-2001", "Hungary-2002", "Hungary-2003",
"Hungary-2004", "Hungary-2005", "Hungary-2006", "Hungary-2007",
"Hungary-2008", "Hungary-2009", "Hungary-2010", "Hungary-2011",
"Hungary-2012", "Hungary-2013", "Hungary-2014", "Hungary-2015",
"Hungary-2016", "Hungary-2017", "Hungary-2018", "Hungary-2019",
"Latvia-1998", "Latvia-1999", "Latvia-2000", "Latvia-2001", "Latvia-2002",
"Latvia-2003", "Latvia-2004", "Latvia-2005", "Latvia-2006", "Latvia-2007",
"Latvia-2008", "Latvia-2009", "Latvia-2010", "Latvia-2011", "Latvia-2012",
"Latvia-2013", "Latvia-2014", "Latvia-2015", "Latvia-2016", "Latvia-2017",
"Latvia-2018", "Latvia-2019", "Lithuania-1998", "Lithuania-1999",
"Lithuania-2000", "Lithuania-2001", "Lithuania-2002", "Lithuania-2003",
"Lithuania-2004", "Lithuania-2005", "Lithuania-2006", "Lithuania-2007",
"Lithuania-2008", "Lithuania-2009", "Lithuania-2010", "Lithuania-2011",
"Lithuania-2012", "Lithuania-2013", "Lithuania-2014", "Lithuania-2015",
"Lithuania-2016", "Lithuania-2017", "Lithuania-2018", "Lithuania-2019",
"Poland-1998", "Poland-1999", "Poland-2000", "Poland-2001", "Poland-2002",
"Poland-2003", "Poland-2004", "Poland-2005", "Poland-2006", "Poland-2007",
"Poland-2008", "Poland-2009", "Poland-2010", "Poland-2011", "Poland-2012",
"Poland-2013", "Poland-2014", "Poland-2015", "Poland-2016", "Poland-2017",
"Poland-2018", "Poland-2019", "SlovakRepublic-1998", "SlovakRepublic-1999",
"SlovakRepublic-2000", "SlovakRepublic-2001", "SlovakRepublic-2002",
"SlovakRepublic-2003", "SlovakRepublic-2004", "SlovakRepublic-2005",
"SlovakRepublic-2006", "SlovakRepublic-2007", "SlovakRepublic-2008",
"SlovakRepublic-2009", "SlovakRepublic-2010", "SlovakRepublic-2011",
"SlovakRepublic-2012", "SlovakRepublic-2013", "SlovakRepublic-2014",
"SlovakRepublic-2015", "SlovakRepublic-2016", "SlovakRepublic-2017",
"SlovakRepublic-2018", "SlovakRepublic-2019", "Slovenia-1998"
), class = c("pdata.frame", "data.frame"), index = structure(list(
Country = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L), .Label = c("CzechRepublic",
"Estonia", "Hungary", "Latvia", "Lithuania", "Poland", "SlovakRepublic",
"Slovenia"), class = "factor"), Year = structure(c(1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L), .Label = c("1998",
"1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006",
"2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014",
"2015", "2016", "2017", "2018", "2019"), class = "factor")), class = c("pindex",
"data.frame"), row.names = c(NA, 155L))) ")

Thank you. Please I have pasted the data below.

Thank you. Please I have pasted the data.

@Benny.owusuk It seems you are fairly new to RStudio Community. I suggest that you use code blocks for copying and pasting code next time, just like what I do in this post.

My solution to your question assumes that you have the data loaded in your R session. I added a few comments to guide you through the code; however, let me know if you have any questions.

# Load packages

library(cointReg)
library(boot)

# Create functions for extracting model estimates

compute_D_estimate <- function(dep_vars, ind_vars, data, indices){
  d <- data[indices, ]
  mod <- cointRegD(d[, ind_vars], d[, dep_vars], n.lead = 1, n.lag = 1,
                   kmax = "k4", info.crit = "AIC", demeaning = FALSE,
                   check = TRUE)
  mod$theta
}

compute_FM_estimate <- function(dep_vars, ind_vars, data, indices){
  d <- data[indices, ]
  mod <- cointRegFM(d[, ind_vars], d[, dep_vars], demeaning = "false")
  mod$theta
}

# Bootstrap DOLS estimate with 1000 replications

boot_D_results <- boot(data = Final_data_c, dep_vars = "ham_rev", ind_vars = "ham_exp", statistic = compute_D_estimate, R = 1000)

boot_D_results # Check bootstrap results
plot(boot_D_results) # Visualize bootstrap results
boot.ci(boot_D_results, type = "basic") # 95% bootstrap confidence interval

# Bootstrap FMOLS estimate with 1000 replications

boot_FM_results <- boot(data = Final_data_c, dep_vars = "ham_rev", ind_vars = "ham_exp", statistic = compute_FM_estimate, R = 1000)

boot_FM_results # Check bootstrap results
plot(boot_FM_results) # Visualize bootstrap results
boot.ci(boot_FM_results, type = "basic") # 95% bootstrap confidence interval
1 Like

Dear @gueyenono, Thank you so much for the support. I implemented the codes and it worked perfectly. I am grateful sir! Thank you once again

You're very welcome @Benny.owusuk. Consider marking my answer as the solution if it helped you!

Done Sir!. Thank you once again. Appreciated

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.