adamlilith / enmSdmX

Tools for Modeling Niches and Distributions of Species
Other
21 stars 2 forks source link

BRT, GLM and GAM showing some error #29

Open ratneshkarjee opened 1 year ago

ratneshkarjee commented 1 year ago

Dear @adamlilith,

I'm a new user and really appreciate this wonderful package. I am getting some errors. However, it ran smoothly when I used lemurs data.

Following steps I am getting the error:

first error:

cur_glm <- trainGLM(data = bioCUR, resp = 'bg_pCUR', preds = cur, verbose = TRUE, cores = 8)

Term-by-term evaluation:

################################ 

                       formula     AICc

1 bio_15 + bio_18 + bio_15:bio_18 55.34421 2 bio_19 + bio_4 + bio_19:bio_4 57.00321 3 bio_4 + bio_19 + bio_4:bio_19 57.00321 4 bio_4 + I(bio_4^2) 58.16015 5 bio_15 + bio_19 + bio_15:bio_19 59.00328 6 bio_4 59.15838 . . 35 bio_9 + I(bio_9^2) 68.31131 36 bio_9 69.13251 37 bio_3 + bio_9 + bio_3:bio_9 70.21528 Error: cannot allocate vector of size 512.0 Gb

Second Error:

cur_gam <- trainGAM(data = bioCUR, resp = 'bg_pCUR', preds = cur, verbose = TRUE, cores = 4) Error in { : task 12 failed - "Repeated variables as arguments of a smooth are not permitted" In addition: Warning messages: 1: In for (i in seq_along(new)) assign(names[i], new[[i]], envir = options) : closing unused connection 6 (<-DESKTOP-7IET5NO:11809) 2: In for (i in seq_along(new)) assign(names[i], new[[i]], envir = options) : closing unused connection 5 (<-DESKTOP-7IET5NO:11809) 3: In for (i in seq_along(new)) assign(names[i], new[[i]], envir = options) : closing unused connection 4 (<-DESKTOP-7IET5NO:11809) 4: In for (i in seq_along(new)) assign(names[i], new[[i]], envir = options) : closing unused connection 3 (<-DESKTOP-7IET5NO:11809)

Third Error:

cur_brt <- trainBRT(data = envSub,resp = 'bg_pCUR',preds = cur, learningRate = 0.001, treeComplexity = 3, minTrees = 1200, maxTrees = 1200, tryBy = 'treeComplexity',anyway = TRUE, verbose = TRUE,cores = 4)

arningRate treeComplexity bagFraction maxTrees stepSize nTrees converged deviance 1 0.001 3 0.6 1200 50 NA FALSE NA 2 0.001 2 0.6 1200 50 NA FALSE NA 3 0.001 3 0.6 1200 50 NA FALSE NA 4 0.001 2 0.6 1200 50 NA FALSE NA 5 0.001 1 0.6 1200 50 NA FALSE NA 6 0.001 2 0.6 1200 50 NA FALSE NA

Warning message: In trainBRT(data = envSub, resp = "bg_pCUR", preds = cur, learningRate = 0.001, : No models converged and/or had sufficient trees.

Please help me in this regard.

Thanks with regards Ratnesh

adamlilith commented 4 months ago

Hi Ratnesh,

I am very sorry, I obviously didn't see the notification when you posted this! I assume it's too tale to help, but for what it's worth:

Error with trainGLM(), "Error: cannot allocate vector of size 512.0 Gb"

This is R's way of saying it ran out of memory. I am guessing the training data set you are using is very large. You could try reducing the number of cores being used by the function.

Error with trainGAM(), "Repeated variables as arguments of a smooth are not permitted".

I am sorry, but I would need to see the data frame being used to train the model. The error is saying that the code is trying to use the same variable twice in a smooth term (e.g., s(x1, x1)). However, I can't recreate the error.

Error with trainBRT(): "No models converged and/or had sufficient trees."

This error message says exactly what is happening: no models converged or had a sufficient number of trees to be minimally sufficient. The function does have some features that automatically attempt to fix this, but I can't do it in all cases. There are a few issues that can cause this. First, does your data have just a few presences? It may be hard to create a model in such case with BRTs because it can be hard to create any model with just a few presences. The data may simply be insufficient. Second, BRTs are stochastic, so my next suggestion is to try to run the function again. Sometimes it takes a few attempts for the system to find a "good" tree. My third suggestion is to try larger values of treeComplexity and/or maxTrees, and/or smaller values of learningRate. This is what the automatic procedure is doing, but you may be able to manually find a solution that it cannot.

Best--and very sorry for the extremely late reply! I have changed the setting so I get notifications about issues!

A