Re: [R] Convergence in Monte Carlo Simulation

2020-06-15 Thread Phat Chau
Dear Michael, So I shouldn't be setting the seed at all then since it is automatic? Or is the suggestion here that a new seed is chosen each time? I think rather than having you guess at the problem (my apologies) I will post the entire of the code (with omissions where it is not directly impa

Re: [R] Convergence in Monte Carlo Simulation

2020-06-14 Thread Michael Dewey
Dear Edward Every time you call your function powercrosssw() it resets the seed so you must be calling it multiple times in some way. Michael On 14/06/2020 13:57, Phat Chau wrote: Thank you Michael. I will clarify some more. The function in the first part of the code that I posted generate

Re: [R] Convergence in Monte Carlo Simulation

2020-06-14 Thread Phat Chau
Thank you Michael. I will clarify some more. The function in the first part of the code that I posted generates the simulated dataset for a cluster randomized trial from the simstudy package. I am not quite clear what you mean by placing it outside the loop. So the goal here is to create n =

Re: [R] Convergence in Monte Carlo Simulation

2020-06-14 Thread Michael Dewey
I am not 100% clear what your code is doing as it gets a bit wangled as you posted in HTML but here are a couple of thoughts. You need to set the seed outside any loops so it happens once and for all. I would test after trycatch and keep a separate count of failures and successes as the failur

Re: [R] Convergence in Monte Carlo Simulation

2020-06-14 Thread Phat Chau
Hello, I put together the following code and am curious about its correctness. My first question relates to the Monte Carlo simulations – the goal is to continue to iterate until I get n = 1000 simulations where the model successfully converges. I am wondering if I coded it correctly below with