dipetkov / eems

Estimating Effective Migration Surfaces
GNU General Public License v2.0
102 stars 28 forks source link

Posterior trace - nan in output #21

Open grafau opened 6 years ago

grafau commented 6 years ago

Hi there!

While I was using eems and plotting functions, i managed to get migration maps but no diagnostic figures are being generated. I got the following error:

Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf

I figured posteriors might be in mcmcpilogl.txt file and mine has only 'nan' in second column. What could cause such behaviour? Any help would be appreciated. In general, I couldn't find the annotation for output files in the manual. It would be super handy!

Thanks! Rafal

dipetkov commented 6 years ago

You are correct that mcmcpilogl.txt stores the prior in the first column and the likelihood in the second column (on the log scale, after burn-in and thinning; the log posterior is column 1 + column 2).

So if the likelihood is nan something has definitely gone wrong. If you've saved the output or if you can run eems again, can you track the likelihood from its initial value? Is it nan at the start or it becomes nan after some number of iterations. (You can set numBurnIter = 0 and numThinIter = 0, so that information about every iteration is printed while runeems is running.)

Here is some example output:


......

Initial log prior: 418.93
Initial log llike: 158288.63

......

Ending iteration 1 ......
         Log prior = 367.01
         Log llike = 163507.44

......
emilyostrow commented 2 years ago

Hello, I am having the same problem. I am using boost version 1.76 and eigen version 3.3.9 with a copy of eems that I downloaded today. I believe that my files are formatted correctly by checking your files, so I am not sure what is causing this problem. To address your above question, the log llike value is always nan from the beginning on every iteration. I am attaching my files here if it helps identify the problem. Thank you for your help.

params.txt datapath.coord.txt datapath.diffs.txt datapath.outer.txt

dipetkov commented 2 years ago

I suspect there is linear dependence among the sampled individuals.

I sub-sampled 50 out of the 89 individuals and then EEMS runs fine.

coord <- read.table("datapath.coord")
outer <- read.table("datapath.outer")
diffs <- read.table("datapath.diffs")

n <- ncol(mat)
m <- 50

idx <- sample(n, m)

coord <- coord[idx, ]
diffs <- diffs[idx, idx]

write.table(coord, "sample.coord", row.names = FALSE, col.names = FALSE)
write.table(outer, "sample.outer", row.names = FALSE, col.names = FALSE)
write.table(diffs, "sample.diffs", row.names = FALSE, col.names = FALSE)