Hi-
I'm running a model in Pystan (v 2.9), and every other iteration samples parameters (not transformed parameters!) with a value of NaN. How could this be?
My code is complicated and I'm still trying to put together a more readable minimal case that produces this error, but I hope that this description is informative enough for someone to point me in the right direction to understand this bug. I have some print statements at the start of the transformed parameters block that output the following parameter values every other update step (they match the initialization values):
SAMP1_purity: 0.914012
SAMP2_purity: 0.247057
SAMP1_frac_of_copiesAfterFirst_with_variant: [0.142037,0.281514,0.0910376,0.143587,0.319623,0.2782,0.280738,0.916913,0.560325,0.509864,0.283772,0.69511,0.65195,0.470809,0.289977,0.820358]
SAMP2_frac_of_copiesAfterFirst_with_variant: [0.715766,0.780833,0.261801,0.39491,0.466047,0.423018,0.0985913,0.433004,0.0576419,0.388036,0.467438,0.400268,0.210212,0.698076,0.320253,0.757758]
mutscale: 7
branching_ratio: 0.290607
subclonal_ccf_threshold: 0.290671
All parameters are bounded by (0,1), except for "mutscale" (any positive real) and "subclonal_ccf_threshold" (lower and upper bounds inputted as data).
Then, every other step my debug statements report that the parameter values have jumped to something like this:
SAMP1_purity: nan
SAMP2_purity: 0.0945089
SAMP1_frac_of_copiesAfterFirst_with_variant: [nan,0.676121,0.193679,0.071821,0.195353,0.451964,0.0692894,0.938367,0.113031,0.177153,0.283759,0.644974,0.78866,0.698519,0.569782,0.589965]
SAMP2_frac_of_copiesAfterFirst_with_variant: [0.918435,0.572717,0.285158,0.347458,0.525633,0.324575,0.183818,0.0963494,0.229748,0.261654,0.750091,0.825402,0.475699,0.923896,0.713328,0.737275]
mutscale: 2.05918
branching_ratio: 0.701423
subclonal_ccf_threshold: nan
These parameter values (appropriately) result in a log-likelihood of NaN and a Metropolis rejection -- after which the sampler returns to the original values, above. Each rejected sample has the same three parameters set to NaN (SAMP1_purity, SAMP1_frac_of_copiesAfterFirst_with_variant[1], and subclonal_ccf_threshold). With each successive failed sample, all other non-NaN parameters get closer to the original initialized value, until I receive this error: "RuntimeError: No acceptably small step size could be found. Perhaps the posterior is not continuous?" Of course, the issue is not that the non-NaN parameters require an impossibly small step size, but that no parameter should ever be set to NaN!
Has anyone ever encountered this sort of behavior before? I've been chopping up my code, but I can't yet isolate what might be causing the issue.
Thanks,
Daniel