wbnicholson/BigVAR

Default T1 causes error

FransAndersen opened this issue · 4 comments

I get an error on row 896 in BigVARObjectClass.R
Error in ZFull$Z[, 1:(v - h)] : only 0's may be mixed with negative subscripts
v=7
h=12

v comes from
for (v in (T1-h+1):T2) { 18-12+1 = 7

T1 is earlier in the code decreased by p on row 579 in BigVARObjectClass.R
T1 <- T1-max(p,s) = 30 - 12 = 18

I use the default T1 when constructing the model;
T1=floor(nrow(Y)/3) = 30

  • Is the default T1 too small when constructing a model? since nrow(Y)/3 < 2h+p+1
  • or is it the wrong character on row 579?

It's hard to set a default value on T1 since it depends on so many other factors, anyway here is a try;

T1_a <- floor(nrow(y) / 3)
T1_b <- 2 * h + p + 1
T2 <- floor(2*nrow(y)/3)

if ( T1_a < T1_b && T1_b < T2 && !recursive && window.size == 0 && object@crossval == "Rolling") {
    T1 <- T1_b
  }else {
    T1 <- T1_a
  }
If ( T1 < T1_b && T2 > T1_b && !recursive && window.size == 0 && object@crossval == "Rolling") {
stop("T1 too small compared to h and p")
}

My default convention shifts T1 and T2 by max(p,s) to account for the initialization. You're right that default values are difficult with varying h,p,s, and series length, but I will try to add a few more checks that are along the lines of your suggestion.

thank you @wbnicholson :-)

Great fix, thank you!