How do i iterate functions until convergence in R?
Generally you want to check that the change in your value of interest becomes very small, eg $abs(X_n - X_{n-1}) &lt; eps$ where eps is a small number like 0.0001.