CSBLatvia/vardpoor

Problem with vardannual (vardpoor version 0.16.0 and newer)

ljozefa opened this issue · 2 comments

Calculating the quality with the vardannual function (vardpoor version 0.15.0 and older) was not a problem, but now, despite the syntax and data not being changed, it is not possible to obtain reliable results when using vardpoor newer versions.

  • When using version 0.16.0 the estimates obtained are the same as those obtained with the older version of the package (eg 0.15.0), but the precision values, such as standard error, coefficient of variation and others, are only consistent for the overall estimates (Dom = NULL). For group estimates (Dom is indicated in the function), the accuracy values differ significantly, despite the fact that the code and data have not changed.

  • When using version 0.17.0 an error message with a warning is shown:

Error in setnames(res, namesY2, namesY2w) : 
  Items of 'old' not found in column names: [ekakt_tot, ekakt_vir, ekakt_siev, ekakt_2064, ekakt_2064_vir, ekakt_2064_siev, bezd_tot, bezd_vir, bezd_siev, nod_2064, ...]. Consider skip_absent=TRUE.
In addition: Warning messages:
1: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 2 rows but longest item has 4663; recycled with remainder.
2: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 2 rows but longest item has 4929; recycled with remainder.

  • When using version 0.20.0 an error message with a warning is shown:
Error: cannot allocate vector of size 38 Kb
In addition: Warning messages:
1: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 2 rows but longest item has 4663; recycled with remainder.
2: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 2 rows but longest item has 4929; recycled with remainder.

Possible answer for problem Error in setnames(...) (vardpoor version 17.0).
Change this part

res <- lapply(split(DT1[, .I], ind_period), function(i)
    data.table(DT1[i, nos, with = FALSE],
      res <- residual_est(Y = DT1[i, namesY2, with = FALSE],
                                   X = DT1[i, names(X), with = FALSE],
                                   weight = DT1[i][["w_design"]],
                                   q = DT1[i][["q"]], dataset = NULL,
                                   checking = FALSE)))
  res <- rbindlist(res)

to

res <- lapply(split(DT1[, .I], ind_period), function(i) {
    resid <- residual_est(Y = DT1[i, namesY2, with = FALSE], 
                          X = DT1[i, names(X), with = FALSE], weight = DT1[i][["w_design"]], 
                          q = DT1[i][["q"]], dataset = NULL, checking = FALSE)
    pers0 <- DT1[i, .N, keyby = c(nos[2:length(nos) - 
                                        1])]
    list(data.table(DT1[i, nos, with = FALSE], resid$residuals), 
         data.table(pers0[, `:=`(N, NULL)], resid$betas))
  })
  betas <- rbindlist(lapply(res, function(x) x[[2]]))
  res <- rbindlist(lapply(res, function(x) x[[1]]))

This has been implemented by 99300f0