I propose a small pull request to fix two small issues:
icarus declares an error when all margins are zero and the method is not linear. Indeed, in order to check that the optimization algorithm has converged, icarus checks that at iteration $t$, $\displaystyle |\frac{\hat{t}_{y,{HT}} - t_y}{t_y}| < \varepsilon$. If $t_y$ is zero, then there is an error and the optimization algorithm cannot continue.
the icarus optimization algorithm doesn't have the same stopping criteria as the SAS Calmar2 macro. In this macro, the algorithm stops when $\max_{k \in S} |\frac{w_k^{(t)}}{d_k} - \frac{w_k^{(t-1)}}{d_k}|$ where $w_k^{(t)}$ denotes the calibrated weight for unit $k$ after $t$ iterations. In a context where, at the French National Institute of Statistics, we transform a lot of SAS pipelines into R, we sometimes notice discrepancies.
I propose to add a tolDefinition argument to the icarus::calibration function (and also icarus::calib, icarus::calibAlgorithm) which allows you to choose the stopping criterion. For the moment, there are two possible choices: sas which is compatible with the SAS CALMAR 2 definition and default which is the initial choice in Icarus (and the default choice).
I added unit tests (see 4d43d98) based on a simulated dataset and calibrated weights computed both in SAS CALMAR 2 and icarus : for some tolerance threshold, weights are not the same if one does not use tolDefinition = "sas".
I have a little issue with the folder data in the package : since I added several datasets to run unit tests, the folder became heavier (around 6 Mb) and I got a warning and a note while using devtools::check. I tried several compression option but I still get this issue. A fix can be to put to False : LazyData in DESCRIPTION
Hi @haroine ,
I hope you're well.
I propose a small pull request to fix two small issues:
icarus
declares an error when all margins are zero and the method is not linear. Indeed, in order to check that the optimization algorithm has converged,icarus
checks that at iteration $t$, $\displaystyle |\frac{\hat{t}_{y,{HT}} - t_y}{t_y}| < \varepsilon$. If $t_y$ is zero, then there is an error and the optimization algorithm cannot continue.Here's a small example:
icarus
optimization algorithm doesn't have the same stopping criteria as the SAS Calmar2 macro. In this macro, the algorithm stops when $\max_{k \in S} |\frac{w_k^{(t)}}{d_k} - \frac{w_k^{(t-1)}}{d_k}|$ where $w_k^{(t)}$ denotes the calibrated weight for unit $k$ after $t$ iterations. In a context where, at the French National Institute of Statistics, we transform a lot of SAS pipelines into R, we sometimes notice discrepancies.I propose to add a
tolDefinition
argument to theicarus::calibration
function (and alsoicarus::calib
,icarus::calibAlgorithm
) which allows you to choose the stopping criterion. For the moment, there are two possible choices:sas
which is compatible with the SAS CALMAR 2 definition anddefault
which is the initial choice in Icarus (and the default choice).I added unit tests (see 4d43d98) based on a simulated dataset and calibrated weights computed both in SAS CALMAR 2 and
icarus
: for some tolerance threshold, weights are not the same if one does not usetolDefinition = "sas"
.I have a little issue with the folder data in the package : since I added several datasets to run unit tests, the folder became heavier (around 6 Mb) and I got a warning and a note while using
devtools::check
. I tried several compression option but I still get this issue. A fix can be to put toFalse
:LazyData
in DESCRIPTION