wxguillo / machuruku

Machuruku
30 stars 2 forks source link

machu.1.tip.resp Error: (max.err>tol) Matrix seems not sysmetric #10

Open prisilveira opened 2 months ago

prisilveira commented 2 months ago

Dear Wilson Guillory,

First of all, thanks for developing such a nice and useful tool. I am trying to run the function "machu.1.tip.resp" to estimate response curves. However, I keep getting the following error message:

Error in if (max.err > tol) warning("matrix seems not symmetric") : missing value where TRUE/FALSE needed

It appears around 30 seconds after running the function. I entered the following line resp_cur <- machu.1.tip.resp(clean_occ, current, verbose = T) and here's the output:

[1] "The following taxa have fewer than 10 occurrence points: Mdis" [1] "Warning: adding random points up to n=10 for each of these species, contained within MCP defined by points." [1] "'clim' is a SpatRaster, attempting to convert to RasterStack for compatibility with dismo::bioclim..." Error in if (max.err > tol) warning("matrix seems not symmetric") : missing value where TRUE/FALSE needed

I think it may be something with the bioclim function though.

I am using R version 4.2.3

Kind regards Priscila

wxguillo commented 1 month ago

Hi Priscila, I haven't seen this error before. It's difficult for me to know what is causing the issue without looking at your data. If you haven't already, I would try going through the machu.1 function line-by-line until you can identify the line that is causing the error, then see if you can fix it. If not, send me your code and data, and I can look at it for you. Best, Wilson

wxguillo commented 1 month ago

Hi Priscila, I believe I've fixed this issue while helping another user. I introduced a "jitter" argument to the machu.1.tip.resp function, which adds some very slight variation to the sampled climate response values before passing them to sn::selm, which seems to solve the problem. If you run the function with jitter=T, I believe it should fix your issue. I passed this update to Github, so you'll have to reinstall the package to use it. Best, Wilson

prisilveira commented 3 weeks ago

Hi Wilson,

Thank you very much! I will test it and get back to you as soon as possible. After I wrote the issue here for the first time, I was able to run the function for some of the rasters but not all. For some, I kept getting the error I described in the previous comment (May 16th).