nsim {rsimsum} | R Documentation |
Compute number of simulations required
Description
The function nsim
computes the number of simulations to perform based on the accuracy of an estimate of interest, using the following equation:
where is the specified level of accuracy of the estimate of interest you are willing to accept (i.e. the permissible difference from the true value
),
is the
quantile of the standard normal distribution,
is the
quantile of the standard normal distribution with
being the power to detect a specific difference from the true value as significant, and
is the variance of the parameter of interest.
Usage
nsim(alpha, sigma, delta, power = 0.5)
Arguments
alpha |
Significance level. Must be a value between 0 and 1. |
sigma |
Variance for the parameter of interest. Must be greater than 0. |
delta |
Specified level of accuracy of the estimate of interest you are willing to accept. Must be greater than 0. |
power |
Power to detect a specific difference from the true value as significant. Must be a value between 0 and 1. Defaults to 0.5, e.g. a power of 50%. |
Value
A scalar value representing the number of simulations to perform based on the accuracy required.
References
Burton, A., Douglas G. Altman, P. Royston. et al. 2006. The design of simulation studies in medical statistics. Statistics in Medicine 25: 4279-4292 doi:10.1002/sim.2673
Examples
# Number of simulations required to produce an estimate to within 5%
# accuracy of the true coefficient of 0.349 with a 5% significance level,
# assuming the variance of the estimate is 0.0166 and 50% power:
nsim(alpha = 0.05, sigma = sqrt(0.0166), delta = 0.349 * 5 / 100, power = 0.5)
# Number of simulations required to produce an estimate to within 1%
# accuracy of the true coefficient of 0.349 with a 5% significance level,
# assuming the variance of the estimate is 0.0166 and 50% power:
nsim(alpha = 0.05, sigma = sqrt(0.0166), delta = 0.349 * 1 / 100, power = 0.5)