**UPDATED:**Ok, one thing that mitigates this is upping the factor on

*runif(1)*to 1e6 or 1e7.

What's going on?

UPDATED: Ok, one thing that mitigates this is upping the factor on runif(1) to 1e6 or 1e7.
I apparently don't know enough about how set.seed() works in R. I'm fitting a model to some 2-D data using the EM algorithm. I do the fit a bunch of times (34 in this case) to look at sensitivity to starting values. I calculate AIC for each fit. To ensure I can run the fit again if I need to, I prefaced the call to my EM algorithm function by setting what I intended to be a random seed. The loop looks like this:
The loop starts at 5 because I happened to do 4 fits before realizing I was missing "set.seed()". Never mind that. The point is that the AICs for these fits cycle around (starting with the 5th). Here's a plot of all 34 AICs:
The default random number generator in R is the Mersenne Twister whose period is $2^{19937}-1$. Call that $L$. The plot above could occur if the number of random number generations my call to the EM algorithm uses, call it $N$ - and $N$ must not depend on the number of iterations needed before convergence, since can vary by fit - the plot above could happen if $L/N=7$. But that's impossible as $N$ is nowhere near that high.
What's going on?
0 Comments
Your comment will be posted after it is approved.
## Leave a Reply. |
## Categories
All
## Archives
December 2016
## AboutThis blog is mainly for statistics, R, or Duke-related stuff that is not |

Powered by

✕