Skip to content

Conversation

@ddueber
Copy link

@ddueber ddueber commented Nov 13, 2025

When searching for a sample size, uniroot wastes HUGE amounts of time narrowing down the fractional part of the solution instead of just stopping when it finds the integer part of the solution. uniroot.integer from the ssanv package will only try integer values. In my tests, this leads to about a 10x speedup. If you don't want to rely on ssanv, all uniroot.integer does is a simple binary search, which is easy enough to code.

When searching for a sample size, uniroot wastes HUGE amounts of time narrowing down the fractional part of the solution instead of just stopping when it finds the integer part of the solution. uniroot.integer from the ssanv package will only try integer values. In my tests, this leads to about a 10x speedup. If you don't want to rely on ssanv, all uniroot.integer does is a simple binary search, which is easy enough to code.
@ddueber
Copy link
Author

ddueber commented Nov 14, 2025

ok, I did a larger scale test and the speedup was more like a factor of 2 with 500 simulations per replication. Still, it was substantial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant