-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in IterationControll for algo Cue and IT #1
Comments
Sorry, I missed that. Many thanks for the report. Your example doesn't demonstrate the problem but the following modification from the examples for
We see that R.4.4.1 throws error (two years ago it was a warning). Your analysis is correct. I think that it is better to just replace
with
i.e., take the max error and leave |
Fixed on github; will be in StableEstim v2.4 (unfortunately, I noticed this issue after submitting a minor fix to CRAN; will need to wait aa month or so before a new release). |
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 ofRelativeErr
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
The text was updated successfully, but these errors were encountered: