tests/testthat/test-isat-sample-issues.R

test_that("Test a the additional.block.search and include.gum arugments",{
  
  data("Nile")
  expect_silent(isat(y = Nile, additional.block.search = TRUE, include.gum = TRUE, print.searchinfo = FALSE))
  
  # check the type of arguments of additional.block.search 
  expect_silent(isat(y = Nile, additional.block.search = FALSE,  print.searchinfo = FALSE))
  expect_error(isat(y = Nile, additional.block.search = "FALSE",  print.searchinfo = FALSE), regexp = "additional.block.search must be logical")
  expect_error(isat(y = Nile, additional.block.search = 0,  print.searchinfo = FALSE), regexp = "additional.block.search must be logical")
  
  # check the type of arguments of include.gum
  expect_silent(isat(y = Nile, include.gum = FALSE,  print.searchinfo = FALSE))
  expect_error(isat(y = Nile, include.gum = "FALSE",  print.searchinfo = FALSE), regexp = "include.gum must be logical")
  expect_error(isat(y = Nile, include.gum = 0,  print.searchinfo = FALSE), regexp = "include.gum must be logical")
  
})



test_that("Trials to ensure the sample sizes work (data from Agg Model)", {
  
  
  yvar <- c(9.50500054078296, 9.51204368579022, 9.53178598658077, 9.54163494187085, 
            9.54104601370306, 9.5541995436028, 9.55526960432986, 9.55139495075547, 
            9.56134929428829, 9.54496089523392, 9.53418319219725, 9.53339441450843, 
            9.52195623259853, 9.52498321451057, 9.53278612436426, 9.53736093910627, 
            9.54181442417258, 9.54857533978779, 9.545897904669, 9.55185700705637, 
            9.55853647189377, 9.55594931293098, 9.56272110899189, 9.55725786645893, 
            9.56396466741496, 9.56484897108349, 9.56939847393666, 9.57641995335005, 
            9.57228540457043, 9.58013685080489, 9.58036481354433, 9.58926983682252, 
            9.60150369537349, 9.60336170986001, 9.60347645571494, 9.62244340026453, 
            9.62463306868703, 9.61699144321864, 9.62229769332068, 9.61905353277881, 
            9.54834714487982, 9.32222158162414, 9.54908858801872, 9.40210057758126, 
            9.29431380575236, 9.45930760329985, 9.586733625931, 9.53116220601524, 
            9.54686260734744, 9.5991475031882, 9.60483889969116)
  
  
  xvars <- structure(
    c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
      32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 
      48, 49, 50, 51, 10.4121378119118, 10.461356100651, 10.4958249582037, 
      10.5088030197225, 10.5199291593254, 10.5314933636153, 10.531218493543, 
      10.5452940691656, 10.5415421251854, 10.5471293131922, 10.551231950267, 
      10.556406312376, 10.5377574899739, 10.5550833059378, 10.5636310540741, 
      10.5619682337501, 10.5653788165704, 10.5746932701207, 10.5868116441473, 
      10.6001261310667, 10.6112991825361, 10.6070527763369, 10.6198262195602, 
      10.6098791374773, 10.6381221062029, 10.6338703040809, 10.6483586847375, 
      10.6377910717171, 10.6686018438119, 10.689031582362, 10.6953572660137, 
      10.7144266576018, 10.7256631902066, 10.7464417069628, 10.7367574799387, 
      10.7558561066275, 10.7894304109339, 10.7774718553287, 10.7771421453244, 
      10.7737594764832, 10.7419161974543, 10.5267834575715, 10.6642022559227, 
      10.6872498172593, 10.6621321693276, 10.7523898394282, 10.7795436173795, 
      10.8184654229847, 10.8265691740356, 10.8623951471904, 10.8858188019862, 
      4.4200447018614, 4.42604352009066, 4.43438186500781, 4.47506150064107, 
      4.44734610079452, 4.4624538837865, 4.47847253294213, 4.48074010760991, 
      4.49200148788245, 4.52070102936164, 4.51633897228148, 4.52504414150881, 
      4.52720864451838, 4.53152364581979, 4.56642935767166, 4.54116485601218, 
      4.55071400019203, 4.57264699428253, 4.56642935767166, 4.56538931597625, 
      4.59915211366253, 4.59309760475382, 4.58394654953646, 4.62301010411642, 
      4.60816569496789, 4.58394654953646, 4.60416968565451, 4.62301010411642, 
      4.62399194022868, 4.65014355163082, 4.66060489287619, 4.65871095291612, 
      4.67095792652609, 4.68213122712422, 4.6931810633108, 4.68767140749983, 
      4.68859179412716, 4.72472942104573, 4.71312732749318, 4.69866052907543, 
      4.78832472908594, 4.79081953287472, 4.73092139129365, 4.80647704269313, 
      4.75100063419963, 4.75874927391639, 4.79081953287472, 4.82751341713153, 
      4.80402104473326, 4.82510860635335, 4.85046654194343, NA, 10.4121378119118, 
      10.461356100651, 10.4958249582037, 10.5088030197225, 10.5199291593254, 
      10.5314933636153, 10.531218493543, 10.5452940691656, 10.5415421251854, 
      10.5471293131922, 10.551231950267, 10.556406312376, 10.5377574899739, 
      10.5550833059378, 10.5636310540741, 10.5619682337501, 10.5653788165704, 
      10.5746932701207, 10.5868116441473, 10.6001261310667, 10.6112991825361, 
      10.6070527763369, 10.6198262195602, 10.6098791374773, 10.6381221062029, 
      10.6338703040809, 10.6483586847375, 10.6377910717171, 10.6686018438119, 
      10.689031582362, 10.6953572660137, 10.7144266576018, 10.7256631902066, 
      10.7464417069628, 10.7367574799387, 10.7558561066275, 10.7894304109339, 
      10.7774718553287, 10.7771421453244, 10.7737594764832, 10.7419161974543, 
      10.5267834575715, 10.6642022559227, 10.6872498172593, 10.6621321693276, 
      10.7523898394282, 10.7795436173795, 10.8184654229847, 10.8265691740356, 
      10.8623951471904, NA, 4.4200447018614, 4.42604352009066, 4.43438186500781, 
      4.47506150064107, 4.44734610079452, 4.4624538837865, 4.47847253294213, 
      4.48074010760991, 4.49200148788245, 4.52070102936164, 4.51633897228148, 
      4.52504414150881, 4.52720864451838, 4.53152364581979, 4.56642935767166, 
      4.54116485601218, 4.55071400019203, 4.57264699428253, 4.56642935767166, 
      4.56538931597625, 4.59915211366253, 4.59309760475382, 4.58394654953646, 
      4.62301010411642, 4.60816569496789, 4.58394654953646, 4.60416968565451, 
      4.62301010411642, 4.62399194022868, 4.65014355163082, 4.66060489287619, 
      4.65871095291612, 4.67095792652609, 4.68213122712422, 4.6931810633108, 
      4.68767140749983, 4.68859179412716, 4.72472942104573, 4.71312732749318, 
      4.69866052907543, 4.78832472908594, 4.79081953287472, 4.73092139129365, 
      4.80647704269313, 4.75100063419963, 4.75874927391639, 4.79081953287472, 
      4.82751341713153, 4.80402104473326, 4.82510860635335, NA, NA, 
      10.4121378119118, 10.461356100651, 10.4958249582037, 10.5088030197225, 
      10.5199291593254, 10.5314933636153, 10.531218493543, 10.5452940691656, 
      10.5415421251854, 10.5471293131922, 10.551231950267, 10.556406312376, 
      10.5377574899739, 10.5550833059378, 10.5636310540741, 10.5619682337501, 
      10.5653788165704, 10.5746932701207, 10.5868116441473, 10.6001261310667, 
      10.6112991825361, 10.6070527763369, 10.6198262195602, 10.6098791374773, 
      10.6381221062029, 10.6338703040809, 10.6483586847375, 10.6377910717171, 
      10.6686018438119, 10.689031582362, 10.6953572660137, 10.7144266576018, 
      10.7256631902066, 10.7464417069628, 10.7367574799387, 10.7558561066275, 
      10.7894304109339, 10.7774718553287, 10.7771421453244, 10.7737594764832, 
      10.7419161974543, 10.5267834575715, 10.6642022559227, 10.6872498172593, 
      10.6621321693276, 10.7523898394282, 10.7795436173795, 10.8184654229847, 
      10.8265691740356, NA, NA, 4.4200447018614, 4.42604352009066, 
      4.43438186500781, 4.47506150064107, 4.44734610079452, 4.4624538837865, 
      4.47847253294213, 4.48074010760991, 4.49200148788245, 4.52070102936164, 
      4.51633897228148, 4.52504414150881, 4.52720864451838, 4.53152364581979, 
      4.56642935767166, 4.54116485601218, 4.55071400019203, 4.57264699428253, 
      4.56642935767166, 4.56538931597625, 4.59915211366253, 4.59309760475382, 
      4.58394654953646, 4.62301010411642, 4.60816569496789, 4.58394654953646, 
      4.60416968565451, 4.62301010411642, 4.62399194022868, 4.65014355163082, 
      4.66060489287619, 4.65871095291612, 4.67095792652609, 4.68213122712422, 
      4.6931810633108, 4.68767140749983, 4.68859179412716, 4.72472942104573, 
      4.71312732749318, 4.69866052907543, 4.78832472908594, 4.79081953287472, 
      4.73092139129365, 4.80647704269313, 4.75100063419963, 4.75874927391639, 
      4.79081953287472, 4.82751341713153, 4.80402104473326, NA, NA, 
      NA, 10.4121378119118, 10.461356100651, 10.4958249582037, 10.5088030197225, 
      10.5199291593254, 10.5314933636153, 10.531218493543, 10.5452940691656, 
      10.5415421251854, 10.5471293131922, 10.551231950267, 10.556406312376, 
      10.5377574899739, 10.5550833059378, 10.5636310540741, 10.5619682337501, 
      10.5653788165704, 10.5746932701207, 10.5868116441473, 10.6001261310667, 
      10.6112991825361, 10.6070527763369, 10.6198262195602, 10.6098791374773, 
      10.6381221062029, 10.6338703040809, 10.6483586847375, 10.6377910717171, 
      10.6686018438119, 10.689031582362, 10.6953572660137, 10.7144266576018, 
      10.7256631902066, 10.7464417069628, 10.7367574799387, 10.7558561066275, 
      10.7894304109339, 10.7774718553287, 10.7771421453244, 10.7737594764832, 
      10.7419161974543, 10.5267834575715, 10.6642022559227, 10.6872498172593, 
      10.6621321693276, 10.7523898394282, 10.7795436173795, 10.8184654229847, 
      NA, NA, NA, 4.4200447018614, 4.42604352009066, 4.43438186500781, 
      4.47506150064107, 4.44734610079452, 4.4624538837865, 4.47847253294213, 
      4.48074010760991, 4.49200148788245, 4.52070102936164, 4.51633897228148, 
      4.52504414150881, 4.52720864451838, 4.53152364581979, 4.56642935767166, 
      4.54116485601218, 4.55071400019203, 4.57264699428253, 4.56642935767166, 
      4.56538931597625, 4.59915211366253, 4.59309760475382, 4.58394654953646, 
      4.62301010411642, 4.60816569496789, 4.58394654953646, 4.60416968565451, 
      4.62301010411642, 4.62399194022868, 4.65014355163082, 4.66060489287619, 
      4.65871095291612, 4.67095792652609, 4.68213122712422, 4.6931810633108, 
      4.68767140749983, 4.68859179412716, 4.72472942104573, 4.71312732749318, 
      4.69866052907543, 4.78832472908594, 4.79081953287472, 4.73092139129365, 
      4.80647704269313, 4.75100063419963, 4.75874927391639, 4.79081953287472, 
      4.82751341713153, NA, NA, NA, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, 10.6381221062029, 10.6338703040809, 
      10.6483586847375, 10.6377910717171, 10.6686018438119, 10.689031582362, 
      10.6953572660137, 10.7144266576018, 10.7256631902066, 10.7464417069628, 
      10.7367574799387, 10.7558561066275, 10.7894304109339, 10.7774718553287, 
      10.7771421453244, 10.7737594764832, 10.7419161974543, 10.5267834575715, 
      10.6642022559227, 10.6872498172593, 10.6621321693276, 10.7523898394282, 
      10.7795436173795, NA, NA, NA, NA, 4.4200447018614, 4.42604352009066, 
      4.43438186500781, 4.47506150064107, 4.44734610079452, 4.4624538837865, 
      4.47847253294213, 4.48074010760991, 4.49200148788245, 4.52070102936164, 
      4.51633897228148, 4.52504414150881, 4.52720864451838, 4.53152364581979, 
      4.56642935767166, 4.54116485601218, 4.55071400019203, 4.57264699428253, 
      4.56642935767166, 4.56538931597625, 4.59915211366253, 4.59309760475382, 
      4.58394654953646, 4.62301010411642, 4.60816569496789, 4.58394654953646, 
      4.60416968565451, 4.62301010411642, 4.62399194022868, 4.65014355163082, 
      4.66060489287619, 4.65871095291612, 4.67095792652609, 4.68213122712422, 
      4.6931810633108, 4.68767140749983, 4.68859179412716, 4.72472942104573, 
      4.71312732749318, 4.69866052907543, 4.78832472908594, 4.79081953287472, 
      4.73092139129365, 4.80647704269313, 4.75100063419963, 4.75874927391639, 
      4.79081953287472, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), dim = c(51L, 14L), dimnames = list(
        NULL, c("trend", "ln.Export", "ln.LabCostService", "L1.ln.Export", 
                "L1.ln.LabCostService", "L2.ln.Export", "L2.ln.LabCostService", 
                "L3.ln.Export", "L3.ln.LabCostService", "L4.ln.Export", "L4.ln.LabCostService", 
                "q_2", "q_3", "q_4")))
  
  # works with many indicators retained
  expect_silent(agg_model <- isat(
    y = yvar,
    mxreg = xvars,
    ar = 1:4,
    print.searchinfo = FALSE,
    iis = TRUE,
    sis = TRUE,
    t.pval = 0.001,
    max.block.size = 12, 
    plot = FALSE, 
    additional.block.search = TRUE
  ))
  
  expect_equal(c("iis47", "iis6", "iis8", "iis10", "iis12", "iis14", "iis16", 
                 "iis18", "iis20", "iis22", "iis24", "iis26", "iis28", "iis42", 
                 "iis44", "iis46", "iis48", "iis50", "sis41", "sis42", "sis45", 
                 "sis47", "sis50"), agg_model$ISnames)
  
  expect_output(print(agg_model), regexp = "NOTE: Result includes indicators that exceed the target p-value 't.pval'")
})

test_that("Test include.gum", {
  
  
  yvar <- c(9.50500054078296, 9.51204368579022, 9.53178598658077, 9.54163494187085, 
            9.54104601370306, 9.5541995436028, 9.55526960432986, 9.55139495075547, 
            9.56134929428829, 9.54496089523392, 9.53418319219725, 9.53339441450843, 
            9.52195623259853, 9.52498321451057, 9.53278612436426, 9.53736093910627, 
            9.54181442417258, 9.54857533978779, 9.545897904669, 9.55185700705637, 
            9.55853647189377, 9.55594931293098, 9.56272110899189, 9.55725786645893, 
            9.56396466741496, 9.56484897108349, 9.56939847393666, 9.57641995335005, 
            9.57228540457043, 9.58013685080489, 9.58036481354433, 9.58926983682252, 
            9.60150369537349, 9.60336170986001, 9.60347645571494, 9.62244340026453, 
            9.62463306868703, 9.61699144321864, 9.62229769332068, 9.61905353277881, 
            9.54834714487982, 9.32222158162414, 9.54908858801872, 9.40210057758126, 
            9.29431380575236, 9.45930760329985, 9.586733625931, 9.53116220601524, 
            9.54686260734744, 9.5991475031882, 9.60483889969116)
  
  
  xvars <- structure(
    c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
      32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 
      48, 49, 50, 51, 10.4121378119118, 10.461356100651, 10.4958249582037, 
      10.5088030197225, 10.5199291593254, 10.5314933636153, 10.531218493543, 
      10.5452940691656, 10.5415421251854, 10.5471293131922, 10.551231950267, 
      10.556406312376, 10.5377574899739, 10.5550833059378, 10.5636310540741, 
      10.5619682337501, 10.5653788165704, 10.5746932701207, 10.5868116441473, 
      10.6001261310667, 10.6112991825361, 10.6070527763369, 10.6198262195602, 
      10.6098791374773, 10.6381221062029, 10.6338703040809, 10.6483586847375, 
      10.6377910717171, 10.6686018438119, 10.689031582362, 10.6953572660137, 
      10.7144266576018, 10.7256631902066, 10.7464417069628, 10.7367574799387, 
      10.7558561066275, 10.7894304109339, 10.7774718553287, 10.7771421453244, 
      10.7737594764832, 10.7419161974543, 10.5267834575715, 10.6642022559227, 
      10.6872498172593, 10.6621321693276, 10.7523898394282, 10.7795436173795, 
      10.8184654229847, 10.8265691740356, 10.8623951471904, 10.8858188019862, 
      4.4200447018614, 4.42604352009066, 4.43438186500781, 4.47506150064107, 
      4.44734610079452, 4.4624538837865, 4.47847253294213, 4.48074010760991, 
      4.49200148788245, 4.52070102936164, 4.51633897228148, 4.52504414150881, 
      4.52720864451838, 4.53152364581979, 4.56642935767166, 4.54116485601218, 
      4.55071400019203, 4.57264699428253, 4.56642935767166, 4.56538931597625, 
      4.59915211366253, 4.59309760475382, 4.58394654953646, 4.62301010411642, 
      4.60816569496789, 4.58394654953646, 4.60416968565451, 4.62301010411642, 
      4.62399194022868, 4.65014355163082, 4.66060489287619, 4.65871095291612, 
      4.67095792652609, 4.68213122712422, 4.6931810633108, 4.68767140749983, 
      4.68859179412716, 4.72472942104573, 4.71312732749318, 4.69866052907543, 
      4.78832472908594, 4.79081953287472, 4.73092139129365, 4.80647704269313, 
      4.75100063419963, 4.75874927391639, 4.79081953287472, 4.82751341713153, 
      4.80402104473326, 4.82510860635335, 4.85046654194343, NA, 10.4121378119118, 
      10.461356100651, 10.4958249582037, 10.5088030197225, 10.5199291593254, 
      10.5314933636153, 10.531218493543, 10.5452940691656, 10.5415421251854, 
      10.5471293131922, 10.551231950267, 10.556406312376, 10.5377574899739, 
      10.5550833059378, 10.5636310540741, 10.5619682337501, 10.5653788165704, 
      10.5746932701207, 10.5868116441473, 10.6001261310667, 10.6112991825361, 
      10.6070527763369, 10.6198262195602, 10.6098791374773, 10.6381221062029, 
      10.6338703040809, 10.6483586847375, 10.6377910717171, 10.6686018438119, 
      10.689031582362, 10.6953572660137, 10.7144266576018, 10.7256631902066, 
      10.7464417069628, 10.7367574799387, 10.7558561066275, 10.7894304109339, 
      10.7774718553287, 10.7771421453244, 10.7737594764832, 10.7419161974543, 
      10.5267834575715, 10.6642022559227, 10.6872498172593, 10.6621321693276, 
      10.7523898394282, 10.7795436173795, 10.8184654229847, 10.8265691740356, 
      10.8623951471904, NA, 4.4200447018614, 4.42604352009066, 4.43438186500781, 
      4.47506150064107, 4.44734610079452, 4.4624538837865, 4.47847253294213, 
      4.48074010760991, 4.49200148788245, 4.52070102936164, 4.51633897228148, 
      4.52504414150881, 4.52720864451838, 4.53152364581979, 4.56642935767166, 
      4.54116485601218, 4.55071400019203, 4.57264699428253, 4.56642935767166, 
      4.56538931597625, 4.59915211366253, 4.59309760475382, 4.58394654953646, 
      4.62301010411642, 4.60816569496789, 4.58394654953646, 4.60416968565451, 
      4.62301010411642, 4.62399194022868, 4.65014355163082, 4.66060489287619, 
      4.65871095291612, 4.67095792652609, 4.68213122712422, 4.6931810633108, 
      4.68767140749983, 4.68859179412716, 4.72472942104573, 4.71312732749318, 
      4.69866052907543, 4.78832472908594, 4.79081953287472, 4.73092139129365, 
      4.80647704269313, 4.75100063419963, 4.75874927391639, 4.79081953287472, 
      4.82751341713153, 4.80402104473326, 4.82510860635335, NA, NA, 
      10.4121378119118, 10.461356100651, 10.4958249582037, 10.5088030197225, 
      10.5199291593254, 10.5314933636153, 10.531218493543, 10.5452940691656, 
      10.5415421251854, 10.5471293131922, 10.551231950267, 10.556406312376, 
      10.5377574899739, 10.5550833059378, 10.5636310540741, 10.5619682337501, 
      10.5653788165704, 10.5746932701207, 10.5868116441473, 10.6001261310667, 
      10.6112991825361, 10.6070527763369, 10.6198262195602, 10.6098791374773, 
      10.6381221062029, 10.6338703040809, 10.6483586847375, 10.6377910717171, 
      10.6686018438119, 10.689031582362, 10.6953572660137, 10.7144266576018, 
      10.7256631902066, 10.7464417069628, 10.7367574799387, 10.7558561066275, 
      10.7894304109339, 10.7774718553287, 10.7771421453244, 10.7737594764832, 
      10.7419161974543, 10.5267834575715, 10.6642022559227, 10.6872498172593, 
      10.6621321693276, 10.7523898394282, 10.7795436173795, 10.8184654229847, 
      10.8265691740356, NA, NA, 4.4200447018614, 4.42604352009066, 
      4.43438186500781, 4.47506150064107, 4.44734610079452, 4.4624538837865, 
      4.47847253294213, 4.48074010760991, 4.49200148788245, 4.52070102936164, 
      4.51633897228148, 4.52504414150881, 4.52720864451838, 4.53152364581979, 
      4.56642935767166, 4.54116485601218, 4.55071400019203, 4.57264699428253, 
      4.56642935767166, 4.56538931597625, 4.59915211366253, 4.59309760475382, 
      4.58394654953646, 4.62301010411642, 4.60816569496789, 4.58394654953646, 
      4.60416968565451, 4.62301010411642, 4.62399194022868, 4.65014355163082, 
      4.66060489287619, 4.65871095291612, 4.67095792652609, 4.68213122712422, 
      4.6931810633108, 4.68767140749983, 4.68859179412716, 4.72472942104573, 
      4.71312732749318, 4.69866052907543, 4.78832472908594, 4.79081953287472, 
      4.73092139129365, 4.80647704269313, 4.75100063419963, 4.75874927391639, 
      4.79081953287472, 4.82751341713153, 4.80402104473326, NA, NA, 
      NA, 10.4121378119118, 10.461356100651, 10.4958249582037, 10.5088030197225, 
      10.5199291593254, 10.5314933636153, 10.531218493543, 10.5452940691656, 
      10.5415421251854, 10.5471293131922, 10.551231950267, 10.556406312376, 
      10.5377574899739, 10.5550833059378, 10.5636310540741, 10.5619682337501, 
      10.5653788165704, 10.5746932701207, 10.5868116441473, 10.6001261310667, 
      10.6112991825361, 10.6070527763369, 10.6198262195602, 10.6098791374773, 
      10.6381221062029, 10.6338703040809, 10.6483586847375, 10.6377910717171, 
      10.6686018438119, 10.689031582362, 10.6953572660137, 10.7144266576018, 
      10.7256631902066, 10.7464417069628, 10.7367574799387, 10.7558561066275, 
      10.7894304109339, 10.7774718553287, 10.7771421453244, 10.7737594764832, 
      10.7419161974543, 10.5267834575715, 10.6642022559227, 10.6872498172593, 
      10.6621321693276, 10.7523898394282, 10.7795436173795, 10.8184654229847, 
      NA, NA, NA, 4.4200447018614, 4.42604352009066, 4.43438186500781, 
      4.47506150064107, 4.44734610079452, 4.4624538837865, 4.47847253294213, 
      4.48074010760991, 4.49200148788245, 4.52070102936164, 4.51633897228148, 
      4.52504414150881, 4.52720864451838, 4.53152364581979, 4.56642935767166, 
      4.54116485601218, 4.55071400019203, 4.57264699428253, 4.56642935767166, 
      4.56538931597625, 4.59915211366253, 4.59309760475382, 4.58394654953646, 
      4.62301010411642, 4.60816569496789, 4.58394654953646, 4.60416968565451, 
      4.62301010411642, 4.62399194022868, 4.65014355163082, 4.66060489287619, 
      4.65871095291612, 4.67095792652609, 4.68213122712422, 4.6931810633108, 
      4.68767140749983, 4.68859179412716, 4.72472942104573, 4.71312732749318, 
      4.69866052907543, 4.78832472908594, 4.79081953287472, 4.73092139129365, 
      4.80647704269313, 4.75100063419963, 4.75874927391639, 4.79081953287472, 
      4.82751341713153, NA, NA, NA, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, 10.6381221062029, 10.6338703040809, 
      10.6483586847375, 10.6377910717171, 10.6686018438119, 10.689031582362, 
      10.6953572660137, 10.7144266576018, 10.7256631902066, 10.7464417069628, 
      10.7367574799387, 10.7558561066275, 10.7894304109339, 10.7774718553287, 
      10.7771421453244, 10.7737594764832, 10.7419161974543, 10.5267834575715, 
      10.6642022559227, 10.6872498172593, 10.6621321693276, 10.7523898394282, 
      10.7795436173795, NA, NA, NA, NA, 4.4200447018614, 4.42604352009066, 
      4.43438186500781, 4.47506150064107, 4.44734610079452, 4.4624538837865, 
      4.47847253294213, 4.48074010760991, 4.49200148788245, 4.52070102936164, 
      4.51633897228148, 4.52504414150881, 4.52720864451838, 4.53152364581979, 
      4.56642935767166, 4.54116485601218, 4.55071400019203, 4.57264699428253, 
      4.56642935767166, 4.56538931597625, 4.59915211366253, 4.59309760475382, 
      4.58394654953646, 4.62301010411642, 4.60816569496789, 4.58394654953646, 
      4.60416968565451, 4.62301010411642, 4.62399194022868, 4.65014355163082, 
      4.66060489287619, 4.65871095291612, 4.67095792652609, 4.68213122712422, 
      4.6931810633108, 4.68767140749983, 4.68859179412716, 4.72472942104573, 
      4.71312732749318, 4.69866052907543, 4.78832472908594, 4.79081953287472, 
      4.73092139129365, 4.80647704269313, 4.75100063419963, 4.75874927391639, 
      4.79081953287472, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), dim = c(51L, 14L), dimnames = list(
        NULL, c("trend", "ln.Export", "ln.LabCostService", "L1.ln.Export", 
                "L1.ln.LabCostService", "L2.ln.Export", "L2.ln.LabCostService", 
                "L3.ln.Export", "L3.ln.LabCostService", "L4.ln.Export", "L4.ln.LabCostService", 
                "q_2", "q_3", "q_4")))
  
  # works with many indicators retained
  expect_silent(agg_model2 <- isat(
    y = yvar,
    mxreg = xvars,
    ar = 1:4,
    print.searchinfo = FALSE,
    iis = TRUE,
    sis = TRUE,
    t.pval = 0.001,
    max.block.size = 12, 
    plot = FALSE, 
    additional.block.search = TRUE,
    include.gum = FALSE
  ))
  
  expect_equal(c("iis42", "iis44", "iis46", "iis49", "iis50"), agg_model2$ISnames)
  
  
})



test_that("Test that sample works with simulated data with very few dof", {
  
  expect_error(
    isat(
      rnorm(30),
      mc = FALSE,
      sis = TRUE,
      print.searchinfo = FALSE
    ),
    "GUM regressor matrix is empty"
  )
  
  # set.seed(123)
  # y <- rnorm(20)
  # k = 15
  # xvar <- matrix(rnorm(20*k), ncol = k)
  
  y <- c(-0.560475646552213, -0.23017748948328, 1.55870831414912, 0.070508391424576, 
         0.129287735160946, 1.71506498688328, 0.460916205989202, -1.26506123460653, 
         -0.686852851893526, -0.445661970099958, 1.22408179743946, 0.359813827057364, 
         0.400771450594052, 0.11068271594512, -0.555841134754075, 1.78691313680308, 
         0.497850478229239, -1.96661715662964, 0.701355901563686, -0.472791407727934
  )
  xvar <- structure(c(-1.06782370598685, -0.217974914658295, -1.02600444830724, 
                      -0.72889122929114, -0.625039267849257, -1.68669331074241, 0.837787044494525, 
                      0.153373117836515, -1.13813693701195, 1.25381492106993, 0.426464221476814, 
                      -0.295071482992271, 0.895125661045022, 0.878133487533042, 0.821581081637487, 
                      0.688640254100091, 0.553917653537589, -0.0619117105767217, -0.305962663739917, 
                      -0.380471001012383, -0.694706978920513, -0.207917278019599, -1.26539635156826, 
                      2.16895596533851, 1.20796199830499, -1.12310858320335, -0.402884835299076, 
                      -0.466655353623219, 0.779965118336318, -0.0833690664718293, 0.253318513994755, 
                      -0.028546755348703, -0.0428704572913161, 1.36860228401446, -0.225770985659268, 
                      1.51647060442954, -1.54875280423022, 0.584613749636069, 0.123854243844614, 
                      0.215941568743973, 0.379639482759882, -0.502323453109302, -0.33320738366942, 
                      -1.01857538310709, -1.07179122647558, 0.303528641404258, 0.448209778629426, 
                      0.0530042267305041, 0.922267467879738, 2.05008468562714, -0.491031166056535, 
                      -2.30916887564081, 1.00573852446226, -0.709200762582393, -0.688008616467358, 
                      1.0255713696967, -0.284773007051009, -1.22071771225454, 0.18130347974915, 
                      -0.138891362439045, 0.00576418589988693, 0.38528040112633, -0.370660031792409, 
                      0.644376548518833, -0.220486561818751, 0.331781963915697, 1.09683901314935, 
                      0.435181490833803, -0.325931585531227, 1.14880761845109, 0.993503855962119, 
                      0.54839695950807, 0.238731735111441, -0.627906076039371, 1.36065244853001, 
                      -0.600259587147127, 2.18733299301658, 1.53261062618519, -0.235700359100477, 
                      -1.02642090030678, -0.710406563699301, 0.25688370915653, -0.246691878462374, 
                      -0.347542599397733, -0.951618567265016, -0.0450277248089203, 
                      -0.784904469457076, -1.66794193658814, -0.380226520287762, 0.918996609060766, 
                      -0.575346962608392, 0.607964322225033, -1.61788270828916, -0.0555619655245394, 
                      0.519407203943462, 0.301153362166714, 0.105676194148943, -0.640706008305376, 
                      -0.849704346033582, -1.02412879060491, 0.117646597100126, -0.947474614184802, 
                      -0.490557443700668, -0.256092192198247, 1.84386200523221, -0.651949901695459, 
                      0.235386572284857, 0.0779608495637108, -0.961856634130129, -0.0713080861235987, 
                      1.44455085842335, 0.451504053079215, 0.0412329219929399, -0.422496832339625, 
                      -2.05324722154052, 1.13133721341418, -1.46064007092482, 0.739947510877334, 
                      1.90910356921748, -1.4438931609718, 0.701784335374711, -0.262197489402468, 
                      -1.57214415914549, -1.51466765378175, -1.60153617357459, -0.530906522170303, 
                      -1.4617555849959, 0.687916772975828, 2.10010894052567, -1.28703047603518, 
                      0.787738847475178, 0.76904224100091, 0.332202578950118, -1.00837660827701, 
                      -0.119452606630659, -0.280395335170247, 0.56298953322048, -0.372438756103829, 
                      0.976973386685621, -0.374580857767014, 1.05271146557933, -1.04917700666607, 
                      -1.26015524475811, 3.2410399349424, -0.416857588160432, 0.298227591540715, 
                      0.636569674033849, -0.483780625708744, 0.516862044313609, 0.368964527385086, 
                      -0.215380507641693, 0.0652930335253153, -0.034067253738464, 2.12845189901618, 
                      -0.741336096272828, -1.09599626707466, 0.0377883991710788, 0.310480749443137, 
                      0.436523478910183, -0.458365332711106, -1.06332613397119, 1.26318517608949, 
                      -0.349650387953555, -0.865512862653374, -0.236279568941097, -0.197175894348552, 
                      1.10992028971364, 0.0847372921971965, 0.754053785184521, -0.499292017172261, 
                      0.214445309581601, -0.324685911490835, 0.0945835281735714, -0.895363357977542, 
                      -1.31080153332797, 1.99721338474797, 0.600708823672418, -1.25127136162494, 
                      -0.611165916680421, -1.18548008459731, 2.19881034888372, 1.31241297643351, 
                      -0.265145056696353, 0.54319405923209, -0.41433994791886, -0.476246894615578, 
                      -0.788602837850243, -0.594617267459511, 1.65090746733669, -0.0540281250854405, 
                      0.119245236427584, 0.243687429599092, 1.23247587848534, -0.51606383094478, 
                      -0.992507150392037, 1.67569693240319, -0.441163216905286, -0.723065969939874, 
                      -1.23627311888329, -1.2847157223178, -0.573973479297987, 0.617985817166529, 
                      1.10984813892972, 0.707588353835588, -0.363657297095253, 0.0597499373846007, 
                      -0.70459646368007, -0.71721816157401, 0.88465049897692, -1.01559257860354, 
                      1.95529396549246, -0.0903195939658516, 0.214538826629216, -0.738527704739573, 
                      -0.57438868976327, -1.31701613230524, -0.182925388372727, 0.418982404924464, 
                      0.32430434416138, -0.781536487054751, -0.788621970854002, -0.502198718342861, 
                      1.49606066984635, -1.13730362066574, -0.179051594380198, 1.90236182167893, 
                      -0.100974885328808, -1.35984070382139, -0.664769435274062, 0.485459978904878, 
                      -0.375602871669773, -0.561876363549783, -0.343917234128459, 0.0904966471392212, 
                      1.59850877114583, -0.088565112138884, 1.08079949615152, 0.630754115650567, 
                      -0.113639895506141, -1.5329020028906, -0.52111731755252, -0.489870453138474, 
                      0.0471544327615272, 1.30019867766682, 2.29307897383109, 1.54758105898377, 
                      -0.133150964328944, -1.75652739555764, -0.388779864071743, 0.0892072230732945, 
                      0.845013004067436, 0.962527968484271, 0.684309429416465, -1.39527434979947, 
                      0.849643045633355, -0.446557216427222, 0.174802700161256, 0.0745511771737346, 
                      0.428166764970505, 0.0246749828261399, -1.66747509758566, 0.736495964773442, 
                      0.386026568349676, -0.265651625278222, 0.118144511046681, 0.134038645368463, 
                      0.221019468561002, 1.64084616597749, -0.219050378933476, 0.168065383884658, 
                      1.16838387306909, 1.05418102337692, 1.14526311038036, -0.577468001059557, 
                      2.00248273029283, 0.066700870930183, 1.86685184470686, -1.35090268603071, 
                      0.0209835863542375, 1.24991457096922, -0.715242187222796, -0.752688968217742, 
                      -0.938538703606894, -1.05251327933874, -0.437159533180399, 0.331179172958982, 
                      -2.01421049792072, 0.211980433372292, 1.23667504641657, 2.03757401824044, 
                      1.30117599220059, 0.756774763795962, -1.72673039911433, -0.601506708006782, 
                      -0.352046456582617, 0.703523902756894, -0.105671334003774, -1.25864862806017, 
                      1.68443570809411, 0.911391291795963), dim = c(20L, 15L))
  
  
  
  
  # arx(y = y, mxreg = xvar, plot = TRUE) # it's not a good model - but we still need to be able to deal with it
  # summary(lm(y ~ xvar))
  
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 30), regexp = "Too many x-variables and indicators for the sample size.") # gives error
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 10), regexp = "Too many x-variables and indicators for the sample size.") # gives error
  
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 2, print.searchinfo = FALSE), regexp = "Too many initial indicators returned for SIS")
  
  expect_error(test_model <- isat(y = y, mxreg = xvar, max.block.size = 1, print.searchinfo = FALSE, additional.block.search = FALSE)) # fails
  expect_silent(test_model <- isat(y = y, mxreg = xvar, max.block.size = 1, print.searchinfo = FALSE, additional.block.search = TRUE)) # works
  
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 1, ar.LjungB = NULL,arch.LjungB = NULL, wald.pval = NULL, t.pval = 0.0001, print.searchinfo = FALSE)) # fails
  expect_silent(isat(y = y, mxreg = xvar, max.block.size = 1, ar.LjungB = NULL,arch.LjungB = NULL, wald.pval = NULL, t.pval = 0.0001, print.searchinfo = FALSE, additional.block.search = TRUE)) # works
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 1, ar.LjungB = NULL,arch.LjungB = NULL, wald.pval = NULL, t.pval = 0.00000001, print.searchinfo = FALSE)) # fails
  expect_silent(isat(y = y, mxreg = xvar, max.block.size = 1, ar.LjungB = NULL,arch.LjungB = NULL, wald.pval = NULL, t.pval = 0.00000001, print.searchinfo = FALSE, additional.block.search = TRUE)) # works
  
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 1, t.pval = 0.0001, print.searchinfo = FALSE)) # fails
  expect_silent(isat(y = y, mxreg = xvar, max.block.size = 1, t.pval = 0.0001, print.searchinfo = FALSE, additional.block.search = TRUE)) # works
  expect_error(isat(y = y, mxreg = xvar, max.block.size = 1, t.pval = 0.00000001, print.searchinfo = FALSE)) # fails
  expect_silent(isat(y = y, mxreg = xvar, max.block.size = 1, t.pval = 0.00000001, print.searchinfo = FALSE, additional.block.search = TRUE)) # works
  
  
  expect_equal(test_model$ISnames, c("sis11", "sis15", "sis20"))
  
  y <- c(0.237430272491026, 1.21810861032581, -1.33877428723497, 0.6608202977898, 
         -0.522912376313422, 0.683745521850712, -0.0608219546600742, 0.632960713031451, 
         1.33551761505939, 0.00729009031689879, 1.01755863695209, -1.18843403514798, 
         -0.721604440436015, 1.51921771138818, 0.377387973023929, -2.05222282043373, 
         -1.36403745208238, -0.200781015589121, 0.865779404334488, -0.101883255715222
  )
  xvar <- structure(c(0.624187472020653, 0.959005377787825, 1.67105482886294, 
                      0.0560167332749619, -0.051981906180899, -1.75323735914227, 0.0993275940878275, 
                      -0.571850057895563, -0.974009582804091, -0.17990623104754, 1.01494317274366, 
                      -1.99274848868858, -0.427279287205429, 0.116637283582706, -0.893207570054953, 
                      0.333902942499225, 0.411429920615731, -0.0330361592759917, -2.46589819376003, 
                      2.57145814586664, -0.205299257468199, 0.65119328158767, 0.273766491036548, 
                      1.02467323481835, 0.817659446374088, -0.209793171228509, 0.378167772208507, 
                      -0.945408831123893, 0.856923010899318, -0.461038338884354, 2.41677335378821, 
                      -1.65104889568819, -0.463987242966015, 0.825379862759242, 0.510132546878663, 
                      -0.589481038515, -0.996780742207522, 0.144475704710697, -0.0143074131669134, 
                      -1.79028123726406, 0.034551067133851, 0.190230315692457, 0.174726396981842, 
                      -1.05501704260268, 0.476133278302629, 1.37857013695924, 0.456236403179813, 
                      -1.13558847037434, -0.435645469691905, 0.346103619553607, -0.647045631318269, 
                      -2.15764633501528, 0.884250820028209, -0.829477611624518, -0.573560270768283, 
                      1.50390060900454, -0.774144929605405, 0.845731540189296, -1.26068287881878, 
                      -0.354542403073978, -0.0735560191364783, -1.16865142442436, -0.634748264908909, 
                      -0.0288415529283144, 0.67069596873393, -1.65054654342511, -0.349754239211268, 
                      0.756406438545484, -0.538809159977592, 0.227291921672942, 0.492228570064431, 
                      0.267835015331683, 0.653257679471382, -0.12270866097738, -0.41367651359212, 
                      -2.64314895202898, -0.092941018479472, 0.430284696359987, 0.53539884086815, 
                      -0.555278351313252, 1.77950290977515, 0.286424419628825, 0.126315858458886, 
                      1.27226677946852, -0.718466221319259, -0.450338623924712, 2.39745248004976, 
                      0.011129187220888, 1.63356842140831, -1.43850664491452, -0.190516802042901, 
                      0.378423903636832, 0.300038545205798, -1.00563625951084, 0.0192592746253708, 
                      -1.07742065311198, 0.712703325244282, 1.08477508986065, -2.22498769648741, 
                      1.23569346230014, -1.24104449680849, 0.454769268982633, 0.659902638142608, 
                      -0.199889828101433, -0.645113956859792, 0.16532102124205, 0.438818700714454, 
                      0.883302819948705, -2.05233698390195, -1.63637926805902, 1.43040234118818, 
                      1.04662884711155, 0.435288948907682, 0.71517840711106, 0.917174917641003, 
                      -2.66092279846568, 1.11027709663882, -0.484987596562325, 0.230616830631202, 
                      -0.295157800883577, 0.871964954078744, -0.348472448955611, 0.518503765888248, 
                      -0.390684978638979, -1.09278720910151, 1.21001051044026, 0.740900011274274, 
                      1.72426223915645, 0.0651539325793032, 1.12500274582817, 1.97541905401908, 
                      -0.281482115038967, -1.32295111275522, -0.239351567138116, -0.214041239985383, 
                      0.15168050450932, 1.71230497731928, -0.326143892505348, 0.373004655804915, 
                      -0.227684064895531, 0.0204507085250325, 0.314057663506262, 1.32821469603699, 
                      0.121318377490778, 0.712842320031113, 0.778860029783535, 0.914773270855634, 
                      -0.574394552184383, 1.62688121419468, -0.380956739294013, -0.105784167649752, 
                      1.40405026771417, 1.29408390614558, -1.08999187241124, -0.873071000417463, 
                      -1.35807905937061, 0.181847192619832, 0.164840867918466, 0.364114687355063, 
                      0.552157714218558, -0.601892845985016, -0.993698591098714, 1.0267850560749, 
                      0.751061302606323, -1.5091665373287, -0.0951474508492868, -0.895947822756499, 
                      -2.07075107054196, 0.150120131188143, -0.0792117092585882, -0.097369267513081, 
                      0.216152541801233, 0.882465164396587, 0.205597504483387, -0.616435842873528, 
                      -0.734799251921281, -0.131802793041181, 0.310016986578952, -1.03968035270204, 
                      -0.184308868842384, 0.967267260167914, -0.108280091234486, -0.69842066759439, 
                      -0.27594516842554, 1.11464854536198, 0.550043961214136, 1.23667580008161, 
                      0.139097857161771, 0.410275096490425, -0.558456912348133, 0.605370668930333, 
                      -0.506333542189239, -1.42056550469574, 0.127992965684126, 1.94585121773144, 
                      0.800914339573062, 1.16525338994626, 0.358855723093152, -0.608557178316224, 
                      -0.202240855110284, -0.273248106811925, -0.468699779782087, 0.704167283929716, 
                      -1.19736350236541, 0.866366132112773, 0.864152486225893, -1.19862235906875, 
                      0.639491997900534, 2.43022665234451, -0.557215481941608, 0.844904241408072, 
                      -0.782201845619403, 1.1107114182028, 0.249824719926562, 1.65191539162316, 
                      -1.45897072853692, -0.0512978861253612, -0.526925176125598, -0.197264869076299, 
                      -0.629578742686005, -0.833843580535001, 0.57872237461645, -1.08758071407693, 
                      1.48403093155628, -1.18620658531375, 0.10107915139528, 0.532989286826481, 
                      0.586735339092625, -0.30174666386638, 0.079501995328401, 0.961264151809677, 
                      -1.45646591707643, -0.781739711532082, 0.32040231431661, -0.444781978336992, 
                      1.370003993971, 0.673253863354836, 0.0721667524147558, -1.50775731753668, 
                      0.0261002253262418, -0.316415868196993, -0.102346513520598, -1.18155922705569, 
                      0.498658043829925, -1.03895644030703, -0.22622198144241, 0.381425829451352, 
                      -0.783515789013048, 0.582991405680064, -1.31651040165169, -2.80977467896054, 
                      0.464967990785852, 0.840539826961, -0.285845423591384, 0.504126254591608, 
                      -1.15591652508367, -0.127148606825662, -1.94151837604062, 1.18118089143852, 
                      1.85991086154316, 1.07401226028199, -0.0273469664137418, -0.0333303422759193, 
                      -1.5160676231511, 0.790385343888228, -0.210734180691776, -0.656742925361075, 
                      -1.41202579265831, -0.299762496646272, -0.849061135016708, -0.397030520327837, 
                      -1.2175999877636, 1.6875894829457, -0.0160025272079689, 1.07494507727239, 
                      -2.60169967025765, -0.453197829994837, -0.675482291592071, -1.22292617936591, 
                      1.54660915422409, -1.41528191976949, 0.318390260408025, 0.846436285579692, 
                      0.178190188418023, -0.875255477495516, 0.941165806724167, 0.170588081840838, 
                      -1.06349790638204, -1.38804904760206, 2.08671743449315, -0.678503145418437, 
                      -1.85557165391804, 0.533259362753652, 0.310230256060895, -1.3538343357226, 
                      -1.94295641358195, -0.116302517158606, 1.13939629170942, 0.636124035182149, 
                      -0.492937424161977), dim = c(20L, 15L))
  
  expect_silent(test_model2 <- isat(y = y, mxreg = xvar, max.block.size = 2, print.searchinfo = FALSE,additional.block.search = TRUE))
  expect_equal(test_model2$ISnames, NULL)
  
})



### NOTE: in getsFun the include.gum = TRUE but in getsm it is not!!!

test_that("Sample size issues are dealt with using the Nile data", {
  
  
  data(Nile)
  expect_error(isat(Nile, sis = TRUE, iis = TRUE, plot = TRUE, t.pval = 0.9, print.searchinfo = FALSE), regexp ="Too many initial indicators returned for the union of indicators to estimate a sensible model") # fails
  expect_error(isat(Nile, sis = TRUE, iis = TRUE, plot = TRUE, t.pval = 0.9, ar = 1:3, print.searchinfo = FALSE), regexp ="Too many initial indicators returned for the union of indicators to estimate a sensible model") # fails
  expect_error(isat(Nile, sis = TRUE, iis = TRUE, plot = TRUE, t.pval = 0.9, print.searchinfo = FALSE), regexp ="Too many initial indicators returned for the union of indicators to estimate a sensible model") # fails
  
  expect_silent(isat(Nile, sis = TRUE, iis = TRUE, plot = TRUE, t.pval = 0.01, ar = 1:3, print.searchinfo = FALSE)) # works
  
  # getsm(isat(Nile, sis = TRUE, iis = TRUE, plot = TRUE, t.pval = 0.9, print.searchinfo = TRUE), # fails
  #       ar.LjungB = NULL, arch.LjungB = NULL, plot = TRUE)
  
})


test_that("Some more AggMod Models", {
  
  yvar <- c(9.24603564730063, 9.25812050242372, 9.26062465748544, 9.26326483528407, 
            9.26604940263427, 9.26170816358875, 9.26025371466821, 9.26820353742037, 
            9.27274223708915, 9.27232876931025, 9.26816578554457, 9.26071024013694, 
            9.27962386789443, 9.26810915505848, 9.26566154356414, 9.26622909120608, 
            9.26681521890416, 9.27055079037517, 9.27553805082157, 9.27992240320778, 
            9.27614683893061, 9.27613747576623, 9.28045394857183, 9.28737548444304, 
            9.28878179828274, 9.29246398997633, 9.29849775871239)
  
  xvars <- structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
                       16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 9.52437708971064, 
                       9.52074726853336, 9.5306178935229, 9.53235865162724, 9.52677752571408, 
                       9.52722195883239, 9.52567652120978, 9.5340963847578, 9.53185124345724, 
                       9.53543382942611, 9.53503639755335, 9.5147910620032, 9.54296951909411, 
                       9.53269195115067, 9.53780790192929, 9.53442910569481, 9.53599718937745, 
                       9.54296234870781, 9.5502495526756, 9.55086154344368, 9.54769793086967, 
                       9.55032785145668, 9.55268106973176, 9.56417528684749, 9.56859506745012, 
                       9.56548013813228, 9.57733488552176, NA, 9.52437708971064, 9.52074726853336, 
                       9.5306178935229, 9.53235865162724, 9.52677752571408, 9.52722195883239, 
                       9.52567652120978, 9.5340963847578, 9.53185124345724, 9.53543382942611, 
                       9.53503639755335, 9.5147910620032, 9.54296951909411, 9.53269195115067, 
                       9.53780790192929, 9.53442910569481, 9.53599718937745, 9.54296234870781, 
                       9.5502495526756, 9.55086154344368, 9.54769793086967, 9.55032785145668, 
                       9.55268106973176, 9.56417528684749, 9.56859506745012, 9.56548013813228, 
                       NA, NA, 9.52437708971064, 9.52074726853336, 9.5306178935229, 
                       9.53235865162724, 9.52677752571408, 9.52722195883239, 9.52567652120978, 
                       9.5340963847578, 9.53185124345724, 9.53543382942611, 9.53503639755335, 
                       9.5147910620032, 9.54296951909411, 9.53269195115067, 9.53780790192929, 
                       9.53442910569481, 9.53599718937745, 9.54296234870781, 9.5502495526756, 
                       9.55086154344368, 9.54769793086967, 9.55032785145668, 9.55268106973176, 
                       9.56417528684749, 9.56859506745012, NA, NA, NA, 9.52437708971064, 
                       9.52074726853336, 9.5306178935229, 9.53235865162724, 9.52677752571408, 
                       9.52722195883239, 9.52567652120978, 9.5340963847578, 9.53185124345724, 
                       9.53543382942611, 9.53503639755335, 9.5147910620032, 9.54296951909411, 
                       9.53269195115067, 9.53780790192929, 9.53442910569481, 9.53599718937745, 
                       9.54296234870781, 9.5502495526756, 9.55086154344368, 9.54769793086967, 
                       9.55032785145668, 9.55268106973176, 9.56417528684749, NA, NA, 
                       NA, NA, 9.52437708971064, 9.52074726853336, 9.5306178935229, 
                       9.53235865162724, 9.52677752571408, 9.52722195883239, 9.52567652120978, 
                       9.5340963847578, 9.53185124345724, 9.53543382942611, 9.53503639755335, 
                       9.5147910620032, 9.54296951909411, 9.53269195115067, 9.53780790192929, 
                       9.53442910569481, 9.53599718937745, 9.54296234870781, 9.5502495526756, 
                       9.55086154344368, 9.54769793086967, 9.55032785145668, 9.55268106973176, 
                       0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
                       1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
                       0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
                       0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 
                     dim = c(27L, 9L), 
                     dimnames = list(NULL, c("trend", "ln.FinConsExpGov", "L1.ln.FinConsExpGov", 
                                             "L2.ln.FinConsExpGov", 
                                             "L3.ln.FinConsExpGov", "L4.ln.FinConsExpGov", 
                                             "q_2", "q_3", "q_4")))
  
  expect_error(isat(yvar, ar = 1:4, mxreg = xvars, iis = TRUE, 
                    sis = TRUE, max.block.size = 6, t.pval = 0.0001, print.searchinfo = FALSE, additional.block.search = TRUE), 
               regexp = "too many indicators for the union of indicators even despite additional block search") # gives explicit error message
  
  ##################### 
  
  yvar <- c(9.24603564730063, 9.25812050242372, 9.26062465748544, 9.26326483528407, 
            9.26604940263427, 9.26170816358875, 9.26025371466821, 9.26820353742037, 
            9.27274223708915, 9.27232876931025, 9.26816578554457, 9.26071024013694, 
            9.27962386789443, 9.26810915505848, 9.26566154356414, 9.26622909120608, 
            9.26681521890416, 9.27055079037517, 9.27553805082157, 9.27992240320778, 
            9.27614683893061, 9.27613747576623, 9.28045394857183, 9.28737548444304, 
            9.28878179828274, 9.29246398997633, 9.29849775871239)
  
  xvars <- structure(
    c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 9.52437708971064, 
      9.52074726853336, 9.5306178935229, 9.53235865162724, 9.52677752571408, 
      9.52722195883239, 9.52567652120978, 9.5340963847578, 9.53185124345724, 
      9.53543382942611, 9.53503639755335, 9.5147910620032, 9.54296951909411, 
      9.53269195115067, 9.53780790192929, 9.53442910569481, 9.53599718937745, 
      9.54296234870781, 9.5502495526756, 9.55086154344368, 9.54769793086967, 
      9.55032785145668, 9.55268106973176, 9.56417528684749, 9.56859506745012, 
      9.56548013813228, 9.57733488552176, NA, 9.52437708971064, 9.52074726853336, 
      9.5306178935229, 9.53235865162724, 9.52677752571408, 9.52722195883239, 
      9.52567652120978, 9.5340963847578, 9.53185124345724, 9.53543382942611, 
      9.53503639755335, 9.5147910620032, 9.54296951909411, 9.53269195115067, 
      9.53780790192929, 9.53442910569481, 9.53599718937745, 9.54296234870781, 
      9.5502495526756, 9.55086154344368, 9.54769793086967, 9.55032785145668, 
      9.55268106973176, 9.56417528684749, 9.56859506745012, 9.56548013813228, 
      NA, NA, 9.52437708971064, 9.52074726853336, 9.5306178935229, 
      9.53235865162724, 9.52677752571408, 9.52722195883239, 9.52567652120978, 
      9.5340963847578, 9.53185124345724, 9.53543382942611, 9.53503639755335, 
      9.5147910620032, 9.54296951909411, 9.53269195115067, 9.53780790192929, 
      9.53442910569481, 9.53599718937745, 9.54296234870781, 9.5502495526756, 
      9.55086154344368, 9.54769793086967, 9.55032785145668, 9.55268106973176, 
      9.56417528684749, 9.56859506745012, NA, NA, NA, 9.52437708971064, 
      9.52074726853336, 9.5306178935229, 9.53235865162724, 9.52677752571408, 
      9.52722195883239, 9.52567652120978, 9.5340963847578, 9.53185124345724, 
      9.53543382942611, 9.53503639755335, 9.5147910620032, 9.54296951909411, 
      9.53269195115067, 9.53780790192929, 9.53442910569481, 9.53599718937745, 
      9.54296234870781, 9.5502495526756, 9.55086154344368, 9.54769793086967, 
      9.55032785145668, 9.55268106973176, 9.56417528684749, NA, NA, 
      NA, NA, 9.52437708971064, 9.52074726853336, 9.5306178935229, 
      9.53235865162724, 9.52677752571408, 9.52722195883239, 9.52567652120978, 
      9.5340963847578, 9.53185124345724, 9.53543382942611, 9.53503639755335, 
      9.5147910620032, 9.54296951909411, 9.53269195115067, 9.53780790192929, 
      9.53442910569481, 9.53599718937745, 9.54296234870781, 9.5502495526756, 
      9.55086154344368, 9.54769793086967, 9.55032785145668, 9.55268106973176, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 
    dim = c(27L, 9L), 
    dimnames = list(NULL, c("trend", "ln.FinConsExpGov", "L1.ln.FinConsExpGov", 
                            "L2.ln.FinConsExpGov", "L3.ln.FinConsExpGov", "L4.ln.FinConsExpGov", 
                            "q_2", "q_3", "q_4")))
  
  
  expect_silent(test_model <- isat(yvar, ar = 1:4, mxreg = xvars, iis = TRUE, sis = TRUE, 
                                   additional.block.search = TRUE,
                                   max.block.size = 6, t.pval = 0.001, 
                                   plot = TRUE, print.searchinfo = FALSE)) # works (changed by M-orca 26.06.2026)
  expect_identical(test_model$ISnames, "sis15")
  
  expect_error(test_model <- isat(yvar, ar = 1:4, mxreg = xvars, iis = TRUE, sis = TRUE, 
                                  additional.block.search = FALSE,
                                  max.block.size = 6, t.pval = 0.001, 
                                  plot = TRUE, print.searchinfo = FALSE), 
               regexp = "Too many initial indicators returned for the union of indicators to estimate a sensible model") # fails
  
  
  
  
  
  #######################
  
  yvar <- c(9.33774805289268, 9.3851168695971, 9.39867713442493, 9.42739341373367, 
            9.44700805851025, 9.45293354711171, 9.46821766193576, 9.46848806688813, 
            9.47825076665284, 9.48084830961673, 9.49041608931601, 9.48290626854363, 
            9.47184272664458, 9.47977955011564, 9.48754777613394, 9.49697689803478, 
            9.50040211077473, 9.51625030301476, 9.51394254445992, 9.50304729867571, 
            9.50345018754352, 9.51085228886606, 9.52040262931953, 9.52749143681148, 
            9.54843985534155, 9.55247511771785, 9.55459652090942)
  
  xvars <- structure(
    c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 10.4121378119118, 
      10.461356100651, 10.4958249582037, 10.5088030197225, 10.5199291593254, 
      10.5314933636153, 10.531218493543, 10.5452940691656, 10.5415421251854, 
      10.5471293131922, 10.551231950267, 10.556406312376, 10.5377574899739, 
      10.5550833059378, 10.5636310540741, 10.5619682337501, 10.5653788165704, 
      10.5746932701207, 10.5868116441473, 10.6001261310667, 10.6112991825361, 
      10.6070527763369, 10.6198262195602, 10.6098791374773, 10.6381221062029, 
      10.6338703040809, 10.6483586847375, 4.44265125649032, 4.43793426661218, 
      4.44617445449763, 4.4624538837865, 4.4636066216663, 4.4636066216663, 
      4.47163879336357, 4.48300255201388, 4.48525988931553, 4.50534985070588, 
      4.51415078760092, 4.5152454784601, 4.52504414150881, 4.5368913452348, 
      4.53903038348355, 4.54648118963941, 4.54435804659133, 4.56434819146784, 
      4.57161340245925, 4.57471097850338, 4.5798523780038, 4.58190155904874, 
      4.58700621536042, 4.59612944133594, 4.59713801429083, 4.60116216459055, 
      4.61015772749913, NA, 10.4121378119118, 10.461356100651, 10.4958249582037, 
      10.5088030197225, 10.5199291593254, 10.5314933636153, 10.531218493543, 
      10.5452940691656, 10.5415421251854, 10.5471293131922, 10.551231950267, 
      10.556406312376, 10.5377574899739, 10.5550833059378, 10.5636310540741, 
      10.5619682337501, 10.5653788165704, 10.5746932701207, 10.5868116441473, 
      10.6001261310667, 10.6112991825361, 10.6070527763369, 10.6198262195602, 
      10.6098791374773, 10.6381221062029, 10.6338703040809, NA, 4.44265125649032, 
      4.43793426661218, 4.44617445449763, 4.4624538837865, 4.4636066216663, 
      4.4636066216663, 4.47163879336357, 4.48300255201388, 4.48525988931553, 
      4.50534985070588, 4.51415078760092, 4.5152454784601, 4.52504414150881, 
      4.5368913452348, 4.53903038348355, 4.54648118963941, 4.54435804659133, 
      4.56434819146784, 4.57161340245925, 4.57471097850338, 4.5798523780038, 
      4.58190155904874, 4.58700621536042, 4.59612944133594, 4.59713801429083, 
      4.60116216459055, NA, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, 10.6381221062029, NA, NA, 
      4.44265125649032, 4.43793426661218, 4.44617445449763, 4.4624538837865, 
      4.4636066216663, 4.4636066216663, 4.47163879336357, 4.48300255201388, 
      4.48525988931553, 4.50534985070588, 4.51415078760092, 4.5152454784601, 
      4.52504414150881, 4.5368913452348, 4.53903038348355, 4.54648118963941, 
      4.54435804659133, 4.56434819146784, 4.57161340245925, 4.57471097850338, 
      4.5798523780038, 4.58190155904874, 4.58700621536042, 4.59612944133594, 
      4.59713801429083, NA, NA, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, NA, NA, NA, 4.44265125649032, 
      4.43793426661218, 4.44617445449763, 4.4624538837865, 4.4636066216663, 
      4.4636066216663, 4.47163879336357, 4.48300255201388, 4.48525988931553, 
      4.50534985070588, 4.51415078760092, 4.5152454784601, 4.52504414150881, 
      4.5368913452348, 4.53903038348355, 4.54648118963941, 4.54435804659133, 
      4.56434819146784, 4.57161340245925, 4.57471097850338, 4.5798523780038, 
      4.58190155904874, 4.58700621536042, 4.59612944133594, NA, NA, 
      NA, NA, 10.4121378119118, 10.461356100651, 10.4958249582037, 
      10.5088030197225, 10.5199291593254, 10.5314933636153, 10.531218493543, 
      10.5452940691656, 10.5415421251854, 10.5471293131922, 10.551231950267, 
      10.556406312376, 10.5377574899739, 10.5550833059378, 10.5636310540741, 
      10.5619682337501, 10.5653788165704, 10.5746932701207, 10.5868116441473, 
      10.6001261310667, 10.6112991825361, 10.6070527763369, 10.6198262195602, 
      NA, NA, NA, NA, 4.44265125649032, 4.43793426661218, 4.44617445449763, 
      4.4624538837865, 4.4636066216663, 4.4636066216663, 4.47163879336357, 
      4.48300255201388, 4.48525988931553, 4.50534985070588, 4.51415078760092, 
      4.5152454784601, 4.52504414150881, 4.5368913452348, 4.53903038348355, 
      4.54648118963941, 4.54435804659133, 4.56434819146784, 4.57161340245925, 
      4.57471097850338, 4.5798523780038, 4.58190155904874, 4.58700621536042, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), 
    dim = c(27L, 14L), 
    dimnames = list(NULL, c("trend", "ln.Export", "ln.LabCostManuf", 
                            "L1.ln.Export", "L1.ln.LabCostManuf", "L2.ln.Export", "L2.ln.LabCostManuf", 
                            "L3.ln.Export", "L3.ln.LabCostManuf", "L4.ln.Export", "L4.ln.LabCostManuf", 
                            "q_2", "q_3", "q_4")))
  
  # fails even before indicator selection
  expect_error(isat(
    yvar,
    ar = 1:4,
    mxreg = xvars,
    iis = TRUE,
    sis = TRUE,
    max.block.size = 4,
    t.pval = 0.001
  ), regexp = "Too many x-variables and indicators for the sample size") 
  
  
  
  
  ##########
  
  yvar <- c(9.97640654670701, 9.85037006901104, 9.83240000660679, 10.0227169195287, 
            9.99079392351075, 9.84068991518066, 9.78365380310287, 9.9438577970327, 
            9.94162123277546, 9.77286666314207, 9.73817897086859, 9.91317418525766, 
            9.91345822971696, 9.76553721072131, 9.72781919405252, 9.87903536979018, 
            9.82992141817718, 9.73061919314399, 9.69705306160578, 9.84511600314472, 
            9.86879734512567, 9.73120648094716, 9.70870390546072, 9.86644906858774, 
            9.85866130167149, 9.73279323662715, 9.67395092146712, 9.89864856349062, 
            9.93392887786095, 9.77360902293359, 9.74347553692578, 9.88946950723877, 
            9.8979384848988, 9.71939877512727, 9.6938685680647, 9.87743737386979, 
            9.87439004638118, 9.81313474463352)
  
  
  xvars <- structure(
    c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
      16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
      32, 33, 34, 35, 36, 37, 38, 10.9887984350984, 11.0029195051879, 
      11.0144219446386, 11.0266444753667, 11.0338891636936, 11.0425745754366, 
      11.0448559640918, 11.0471226001459, 11.0540136930062, 11.0474507646262, 
      11.0477087600983, 11.0446994548231, 11.0455647401737, 11.0469042951953, 
      11.0504359340449, 11.0553135404334, 11.0541466016649, 11.05799486471, 
      11.059426481634, 11.0594233340105, 11.0613729619191, 11.0624812962031, 
      11.0697475861918, 11.070801559199, 11.0773634548708, 11.0828069435034, 
      11.0874943562212, 11.0973600197585, 11.1008042540766, 11.1071713150935, 
      11.1140332082692, 11.1208956971183, 11.1288323403097, 11.1319578284625, 
      11.136683180339, 11.1523328569974, 11.1548624152011, 11.152387354317, 
      10.4121378119118, 10.461356100651, 10.4958249582037, 10.5088030197225, 
      10.5199291593254, 10.5314933636153, 10.531218493543, 10.5452940691656, 
      10.5415421251854, 10.5471293131922, 10.551231950267, 10.556406312376, 
      10.5377574899739, 10.5550833059378, 10.5636310540741, 10.5619682337501, 
      10.5653788165704, 10.5746932701207, 10.5868116441473, 10.6001261310667, 
      10.6112991825361, 10.6070527763369, 10.6198262195602, 10.6098791374773, 
      10.6381221062029, 10.6338703040809, 10.6483586847375, 10.6377910717171, 
      10.6686018438119, 10.689031582362, 10.6953572660137, 10.7144266576018, 
      10.7256631902066, 10.7464417069628, 10.7367574799387, 10.7558561066275, 
      10.7894304109339, 10.7774718553287, 9.49591773107191, 9.53177873555384, 
      9.54090232005766, 9.56393658147197, 9.58091033150643, 9.58702870531293, 
      9.59732238182668, 9.59756682913932, 9.60790098840769, 9.60732293816844, 
      9.62028211166698, 9.61717787125796, 9.61298818189073, 9.6213500803397, 
      9.62741120569182, 9.63526818033083, 9.63205933426724, 9.64004921145481, 
      9.63604592002332, 9.62859665640065, 9.62789214121949, 9.63733211062863, 
      9.64436054250162, 9.64488520318451, 9.66048562237165, 9.67119603588743, 
      9.67884287509565, 9.69619889548351, 9.70400559468981, 9.70661463637219, 
      9.71885532820493, 9.72915797463172, 9.73644074057379, 9.74168601271166, 
      9.75260070726806, 9.76940743796268, 9.76914440195382, 9.76240774215428, 
      NA, 9.49591773107191, 9.53177873555384, 9.54090232005766, 9.56393658147197, 
      9.58091033150643, 9.58702870531293, 9.59732238182668, 9.59756682913932, 
      9.60790098840769, 9.60732293816844, 9.62028211166698, 9.61717787125796, 
      9.61298818189073, 9.6213500803397, 9.62741120569182, 9.63526818033083, 
      9.63205933426724, 9.64004921145481, 9.63604592002332, 9.62859665640065, 
      9.62789214121949, 9.63733211062863, 9.64436054250162, 9.64488520318451, 
      9.66048562237165, 9.67119603588743, 9.67884287509565, 9.69619889548351, 
      9.70400559468981, 9.70661463637219, 9.71885532820493, 9.72915797463172, 
      9.73644074057379, 9.74168601271166, 9.75260070726806, 9.76940743796268, 
      9.76914440195382, NA, 10.9887984350984, 11.0029195051879, 11.0144219446386, 
      11.0266444753667, 11.0338891636936, 11.0425745754366, 11.0448559640918, 
      11.0471226001459, 11.0540136930062, 11.0474507646262, 11.0477087600983, 
      11.0446994548231, 11.0455647401737, 11.0469042951953, 11.0504359340449, 
      11.0553135404334, 11.0541466016649, 11.05799486471, 11.059426481634, 
      11.0594233340105, 11.0613729619191, 11.0624812962031, 11.0697475861918, 
      11.070801559199, 11.0773634548708, 11.0828069435034, 11.0874943562212, 
      11.0973600197585, 11.1008042540766, 11.1071713150935, 11.1140332082692, 
      11.1208956971183, 11.1288323403097, 11.1319578284625, 11.136683180339, 
      11.1523328569974, 11.1548624152011, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, 10.6381221062029, 10.6338703040809, 
      10.6483586847375, 10.6377910717171, 10.6686018438119, 10.689031582362, 
      10.6953572660137, 10.7144266576018, 10.7256631902066, 10.7464417069628, 
      10.7367574799387, 10.7558561066275, 10.7894304109339, NA, NA, 
      9.49591773107191, 9.53177873555384, 9.54090232005766, 9.56393658147197, 
      9.58091033150643, 9.58702870531293, 9.59732238182668, 9.59756682913932, 
      9.60790098840769, 9.60732293816844, 9.62028211166698, 9.61717787125796, 
      9.61298818189073, 9.6213500803397, 9.62741120569182, 9.63526818033083, 
      9.63205933426724, 9.64004921145481, 9.63604592002332, 9.62859665640065, 
      9.62789214121949, 9.63733211062863, 9.64436054250162, 9.64488520318451, 
      9.66048562237165, 9.67119603588743, 9.67884287509565, 9.69619889548351, 
      9.70400559468981, 9.70661463637219, 9.71885532820493, 9.72915797463172, 
      9.73644074057379, 9.74168601271166, 9.75260070726806, 9.76940743796268, 
      NA, NA, 10.9887984350984, 11.0029195051879, 11.0144219446386, 
      11.0266444753667, 11.0338891636936, 11.0425745754366, 11.0448559640918, 
      11.0471226001459, 11.0540136930062, 11.0474507646262, 11.0477087600983, 
      11.0446994548231, 11.0455647401737, 11.0469042951953, 11.0504359340449, 
      11.0553135404334, 11.0541466016649, 11.05799486471, 11.059426481634, 
      11.0594233340105, 11.0613729619191, 11.0624812962031, 11.0697475861918, 
      11.070801559199, 11.0773634548708, 11.0828069435034, 11.0874943562212, 
      11.0973600197585, 11.1008042540766, 11.1071713150935, 11.1140332082692, 
      11.1208956971183, 11.1288323403097, 11.1319578284625, 11.136683180339, 
      11.1523328569974, NA, NA, 10.4121378119118, 10.461356100651, 
      10.4958249582037, 10.5088030197225, 10.5199291593254, 10.5314933636153, 
      10.531218493543, 10.5452940691656, 10.5415421251854, 10.5471293131922, 
      10.551231950267, 10.556406312376, 10.5377574899739, 10.5550833059378, 
      10.5636310540741, 10.5619682337501, 10.5653788165704, 10.5746932701207, 
      10.5868116441473, 10.6001261310667, 10.6112991825361, 10.6070527763369, 
      10.6198262195602, 10.6098791374773, 10.6381221062029, 10.6338703040809, 
      10.6483586847375, 10.6377910717171, 10.6686018438119, 10.689031582362, 
      10.6953572660137, 10.7144266576018, 10.7256631902066, 10.7464417069628, 
      10.7367574799387, 10.7558561066275, NA, NA, NA, 9.49591773107191, 
      9.53177873555384, 9.54090232005766, 9.56393658147197, 9.58091033150643, 
      9.58702870531293, 9.59732238182668, 9.59756682913932, 9.60790098840769, 
      9.60732293816844, 9.62028211166698, 9.61717787125796, 9.61298818189073, 
      9.6213500803397, 9.62741120569182, 9.63526818033083, 9.63205933426724, 
      9.64004921145481, 9.63604592002332, 9.62859665640065, 9.62789214121949, 
      9.63733211062863, 9.64436054250162, 9.64488520318451, 9.66048562237165, 
      9.67119603588743, 9.67884287509565, 9.69619889548351, 9.70400559468981, 
      9.70661463637219, 9.71885532820493, 9.72915797463172, 9.73644074057379, 
      9.74168601271166, 9.75260070726806, NA, NA, NA, 10.9887984350984, 
      11.0029195051879, 11.0144219446386, 11.0266444753667, 11.0338891636936, 
      11.0425745754366, 11.0448559640918, 11.0471226001459, 11.0540136930062, 
      11.0474507646262, 11.0477087600983, 11.0446994548231, 11.0455647401737, 
      11.0469042951953, 11.0504359340449, 11.0553135404334, 11.0541466016649, 
      11.05799486471, 11.059426481634, 11.0594233340105, 11.0613729619191, 
      11.0624812962031, 11.0697475861918, 11.070801559199, 11.0773634548708, 
      11.0828069435034, 11.0874943562212, 11.0973600197585, 11.1008042540766, 
      11.1071713150935, 11.1140332082692, 11.1208956971183, 11.1288323403097, 
      11.1319578284625, 11.136683180339, NA, NA, NA, 10.4121378119118, 
      10.461356100651, 10.4958249582037, 10.5088030197225, 10.5199291593254, 
      10.5314933636153, 10.531218493543, 10.5452940691656, 10.5415421251854, 
      10.5471293131922, 10.551231950267, 10.556406312376, 10.5377574899739, 
      10.5550833059378, 10.5636310540741, 10.5619682337501, 10.5653788165704, 
      10.5746932701207, 10.5868116441473, 10.6001261310667, 10.6112991825361, 
      10.6070527763369, 10.6198262195602, 10.6098791374773, 10.6381221062029, 
      10.6338703040809, 10.6483586847375, 10.6377910717171, 10.6686018438119, 
      10.689031582362, 10.6953572660137, 10.7144266576018, 10.7256631902066, 
      10.7464417069628, 10.7367574799387, NA, NA, NA, NA, 9.49591773107191, 
      9.53177873555384, 9.54090232005766, 9.56393658147197, 9.58091033150643, 
      9.58702870531293, 9.59732238182668, 9.59756682913932, 9.60790098840769, 
      9.60732293816844, 9.62028211166698, 9.61717787125796, 9.61298818189073, 
      9.6213500803397, 9.62741120569182, 9.63526818033083, 9.63205933426724, 
      9.64004921145481, 9.63604592002332, 9.62859665640065, 9.62789214121949, 
      9.63733211062863, 9.64436054250162, 9.64488520318451, 9.66048562237165, 
      9.67119603588743, 9.67884287509565, 9.69619889548351, 9.70400559468981, 
      9.70661463637219, 9.71885532820493, 9.72915797463172, 9.73644074057379, 
      9.74168601271166, NA, NA, NA, NA, 10.9887984350984, 11.0029195051879, 
      11.0144219446386, 11.0266444753667, 11.0338891636936, 11.0425745754366, 
      11.0448559640918, 11.0471226001459, 11.0540136930062, 11.0474507646262, 
      11.0477087600983, 11.0446994548231, 11.0455647401737, 11.0469042951953, 
      11.0504359340449, 11.0553135404334, 11.0541466016649, 11.05799486471, 
      11.059426481634, 11.0594233340105, 11.0613729619191, 11.0624812962031, 
      11.0697475861918, 11.070801559199, 11.0773634548708, 11.0828069435034, 
      11.0874943562212, 11.0973600197585, 11.1008042540766, 11.1071713150935, 
      11.1140332082692, 11.1208956971183, 11.1288323403097, 11.1319578284625, 
      NA, NA, NA, NA, 10.4121378119118, 10.461356100651, 10.4958249582037, 
      10.5088030197225, 10.5199291593254, 10.5314933636153, 10.531218493543, 
      10.5452940691656, 10.5415421251854, 10.5471293131922, 10.551231950267, 
      10.556406312376, 10.5377574899739, 10.5550833059378, 10.5636310540741, 
      10.5619682337501, 10.5653788165704, 10.5746932701207, 10.5868116441473, 
      10.6001261310667, 10.6112991825361, 10.6070527763369, 10.6198262195602, 
      10.6098791374773, 10.6381221062029, 10.6338703040809, 10.6483586847375, 
      10.6377910717171, 10.6686018438119, 10.689031582362, 10.6953572660137, 
      10.7144266576018, 10.7256631902066, 10.7464417069628, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 
      0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 
      0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 
      1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 
      0, 0, 0, 1, 0, 0), dim = c(38L, 19L), 
    dimnames = list(NULL, c("trend", 
                            "ln.GDP", "ln.Export", "ln.GValueAddIndus", "L1.ln.GValueAddIndus", 
                            "L1.ln.GDP", "L1.ln.Export", "L2.ln.GValueAddIndus", "L2.ln.GDP", 
                            "L2.ln.Export", "L3.ln.GValueAddIndus", "L3.ln.GDP", "L3.ln.Export", 
                            "L4.ln.GValueAddIndus", "L4.ln.GDP", "L4.ln.Export", "q_2", "q_3", 
                            "q_4")))
  # fails
  expect_error(isat(
    y = yvar,
    mxreg = xvars,
    ar = 1:4,
    plot = TRUE,
    print.searchinfo = FALSE,
    iis = TRUE,
    sis = TRUE,
    t.pval = 0.001,
    max.block.size = 6
  ), regexp = "Too many initial indicators returned for the union of indicators to estimate a sensible model")
  
  # fails
  expect_error(isat(
    y = yvar,
    mxreg = xvars,
    ar = 1:4,
    plot = TRUE,
    print.searchinfo = FALSE,
    iis = TRUE,
    sis = TRUE,
    t.pval = 0.00000001,
    max.block.size = 1
  ), regexp = "Too many initial indicators returned for SIS to estimate a sensible model")
  
  expect_error(isat(
    y = yvar,
    mxreg = xvars,
    ar = 1:4,
    plot = TRUE,
    print.searchinfo = FALSE,
    iis = TRUE,
    sis = TRUE,
    t.pval = 0.00000001,
    max.block.size = 1,
    additional.block.search = TRUE
  ), regexp = "retains too many indicators for SIS even despite additional block search")
  
  
})

Try the gets package in your browser

Any scripts or data that you put into this service are public.

gets documentation built on July 29, 2026, 9:07 a.m.