config-i1 / greybox

Regression model building and forecasting in R
30 stars 7 forks source link

alm.R Line 1137 #51

Closed Steviey closed 3 years ago

Steviey commented 3 years ago

R 4.2, greybox 0.6.7.41009

Hello,

While using ro(), I could locate the root of the error below, to alm.R Line 1137

simpleError in if (any(corHigh)) { removexreg <- unique(which(corHigh, arr.ind = TRUE)[, 1]) matrixXreg <- matrixXreg[, -removexreg, drop = FALSE] nVariables <- ncol(matrixXreg) variablesNames <- colnames(matrixXreg) if (!occurrenceModel && !CDF) { warning("Some exogenous variables were perfectly correlated. We've dropped them out.", call. = FALSE) }}: missing value where TRUE/FALSE needed>

'value where TRUE/FALSE needed' suggests that there will be an empty variable proofed- under certain circumstances. However, since this is highly correlated to individual input data- we could fail to reproduce this error with random data.

For now, I avoid this to be a 'tragic code break' by using a tryCatch(), while searching for the right model.

config-i1 commented 3 years ago

Thanks for this! Unfortunately, it's difficult to understand why this happens without even knowing how alm() was called. If NAs appear in correlation matrix, then there are some missing observations in the data. I can make this a bit more robust by including use="complete.obs" in cor(), but this won't guarantee the fix of the issue.

config-i1 commented 3 years ago

Implemented in greybox v0.6.7.41010. Can you, please, install from github and see whether the issues was fix or not?

Steviey commented 3 years ago

OK Ivan, I will test this. For now, I can mention that all my data is na-imputed by 0, and that it happens while using auto.adam() + ro().

config-i1 commented 3 years ago

This is a useful information. Do you use occurrence in this case?

Steviey commented 3 years ago

Here is an example paramter-setting.

model      regressors         ic    distribution         initial 
"FFF"        "select"           "AIC"       "default"   "backcasting" 
lags          bounds      occurrence          
"5"         "usual"          "none"          
config-i1 commented 3 years ago

Okay. This looks mysterious. Not sure how to track the error. Let's see if the updated version helps...

Steviey commented 3 years ago

R 4.2, greybox v. 0.6.7.41010

It will take some time...it's running... :-)

Steviey commented 3 years ago

Update: This did not do the trick. What I can say is the following. from grid search: In iteration A it has model='MAN' ic='AICc' result: no error In iteration B it has model='FFF' ic='AIC' result: the mentioned error...

<simpleError in if (any(corHigh)) { removexreg <- unique(which(corHigh, arr.ind = TRUE)[, 1]) matrixXreg <- matrixXreg[, -removexreg, drop = FALSE] nVariables <- ncol(matrixXreg) variablesNames <- colnames(matrixXreg) if (!occurrenceModel && !CDF) { warning("Some exogenous variables were perfectly correlated. We've dropped them out.", call. = FALSE) }}: missing value where TRUE/FALSE needed>

I use an external multicollinearity check and separate correlation check beforehand. The methods: auto.adam() + ro() (with xRegs). The data is 0-imputed/has no NA's. xRegs are dimension reduced by PCA and mostly boxCox-transformed. Activated/deactivated boxCox-transform (external), could play a role... I have to check this further.

Steviey commented 3 years ago

Let me know, if there is something new to test out.

config-i1 commented 3 years ago

Hi, I got distracted by my job... :) Can you paste a reproducible example, so that I could investigate and fix?

Steviey commented 3 years ago

At the moment I can't reproduce it anymore Ivan. There are so many changes in your and in my code. Maybe I was wrong on any code part. I let you know, if this happens again.

config-i1 commented 3 years ago

I've been fixing so many bugs recently, that I could have fixed it by accident :) Thanks!

config-i1 commented 3 years ago

I've been fixing so many bugs recently, that I could have fixed it by accident :) Thanks!