Skip to content

Error in IterationControll for algo Cue and IT #1

@cedricjuessen

Description

@cedricjuessen

Dear Colleagues,
for "Due" and "IT" in the IterationControl only the first value from the theta vector is compared with the value from the previous iteration. Therefore, the following warning is generated for the following sample code:

Code:
StableEstim::Estim_Simulation(rbind(c(0.5,1)),c(4), 4, "GMM", HandleError = TRUE, FctsToApply = StatFcts, saveOutput = TRUE, StatSummary = FALSE, CheckMat = TRUE, tolFailCheck = tolFailure, SeedOptions=NULL,algo = "CueGMM", regularization = "Tikhonov", WeightingMatrix = "OptAsym", t_scheme = "free", alphaReg = 0.005, t_free = seq(0.1,2,length.out=12))

Warning:
Warning messages: 1: In (iter < Control$NbIter) && (RelativeErr > Control$RelativeErrMax) : 'length(x) = 4 > 1' in coercion to 'logical(1)'

Since the functions are all similar in structure, I will explain the error on one example. Let's have a look at the function "ComputeITGMMParametersEstim" in the file "GMMParamsEstim.R".
In line 78 while((iter < Control$NbIter) && (RelativeErr > Control$RelativeErrMax) ) RelativeErr is compared to a numeric value. Before, the value of RelativeErr is also set to a numeric value: RelativeErr=Control$RelativeErrMax+5 . In the first iteration, the When condition works fine while two numeric values are compared. No warning is generated.

However, during the first iteration RelativeErr is assinged a vector: RelativeErr <- abs(CurrentEstimParVal-PrevEstimParVal).

To fix the error, I would suggest the following solution:
Set RelativeErr directly as a vector with length 4:
RelativeErr <- rep(Control$RelativeErrMax + 5, times = 4)

Compare for each value from RelativeErr that it satisfies the iteration condition:
while ((iter < Control$NbIter) && ((RelativeErr[1] > RelativeErrMaxArray) || (RelativeErr[2] > RelativeErrMaxArray) || (RelativeErr[3] > RelativeErrMaxArray) || (RelativeErr[4] > RelativeErrMaxArray) )) {
Yours faithfully,
Cedric Jüssen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions