Introduction
Javascript Program
R codes
Sample Size Tables
E
F
G
Studies to detect rare events are usually carried out after the introduction
of a new drug or treatment into general use, to exclude the occurrence of unusual adverse events.
These are sometimes called post marketing studies, or Phase IV Trials.
The idea is to require all users to report side effects or complications, so that
rare adverse outcomes are recorded and dealt with.
The sample size represents a count of the number of negative cases that accompany a nominated number of positive cases, assuming the data has a negative binomial distribution, which is very similar to the Poisson distribution. It is calculated with the following parameters.
- Power (1-β), where β is the probability of Type II Error, so that power is the likelihood that the rare event
will be detected if it exists. The table in the next panel provides sample size for powers of 0.8, 0.9, 0.95, and 0.99.
Although power=0.08 is commonly used in clinical research, the importance of detecting unusual and unexpected adverse outcome
is such that the power used is commonly set at 0.95, or even 0.99 for those adverse outcomes that are life threatening.
- The Mean Event Rate λ, (number of events / number of observations). This is the critical level of probability,
above which is considered unacceptable and requiring remedy. The table in the next panel provides sample size for
λ=0.0001 (1 in 10,000) to λ=0.01 (1%) with 0.0001 intervals.
- The Critical Event Limit r is the pre-determined number of events that, if occurred within the sample size observed,
will led to the conclusion that λ is exceeded. Although r is usually set to 1, the table in the next panel provides
for up to r=3.
- The algorithm calculates sample size required using iterative approximation until all the parameters are satisfied. Clinically,
the sample size is usually rounded upwards to the next thousand.
An example : Using the very first row of the table :
- If we wish to detect an event as rare as 1 in 10,000 (λ=0.0001)
- and if the power of detection is set at 0.95 (95% sure we will detect it if it exists as frequently as 1 in 10,000)
- then we can conclude that the event is more frequent than 1 in 10,000 if we observe 1 incident in 30,000 cases (rounded up from
29958), or two incidents in 48,000 cases (rounded up from 47439), or 3 incidences in 63,000 cases (rounded up from 62960).
The sample size table is constructed using the algorithm described in the reference
Reference
Machin D, Campbell M, Fayers, P, Pinol A (1997) Sample Size Tables for
Clinical Studies. Second Ed. Blackwell Science IBSN 0-86542-870-0 p. 144-145
R codess for sample size to detect rare events
fuctions for calculation
FindB <- function(lambda,n,a) # Poisson coefficient
{
b = 0
for(y in 1:a)
{
x = y - 1
b = b + (n * lambda)^x * exp(-n * lambda) / factorial(x)
}
return (b)
}
SSizAInc <- function(lambda,beta,r) # interative approximation for the correct sample size nm
{
if(r==1)
{
return (-log(beta) / lambda)
}
nL = 2
nR = r * -log(beta) / lambda;
nM = (nL + nR) / 2
bL = FindB(lambda, nL, r) - beta
bR = FindB(lambda, nR, r) - beta
bM = FindB(lambda, nM, r) - beta
if(bL*bR>0)
{
return (0)
}
if(bL*bM>0) { nL = nM } else { nR = nM }
j=0;
while(j<100 & abs(bM)>0.00001)
{
nM = (nL + nR) / 2
bL = FindB(lambda,nL,r) - beta
bM = FindB(lambda,nM,r) - beta
if(bL*bM>0) { nL = nM } else { nR = nM }
j = j + 1
}
return (nM)
}
Main program
# Data entry as a table
myDat = ("
pow lambda r # power, expected proportion, critical tolerance limit
0.90 0.001 1
0.90 0.001 2
0.99 0.002 1
0.99 0.002 3
")
df <- read.table(textConnection(myDat),header=TRUE) # conversion to data frame
df # display input data
# Calculations
ssiz <- vector() # vector (array) to contain sample sizes
for(i in 1:nrow(df))
{
beta = 1 - df$pow[i]
lambda = df$lambda[i]
r = df$r[i]
ssiz <- append(ssiz,ceiling(SSizAInc(lambda,beta,r)))
}
df$SSiz <- ssiz # add sample size column to data frame
df # display input data + sample size calculated
The results are
> df # display input data
pow lambda r
1 0.90 0.001 1
2 0.90 0.001 2
3 0.99 0.002 1
4 0.99 0.002 3
> df # display input data + sample size calculated
pow lambda r SSiz
1 0.90 0.001 1 2303
2 0.90 0.001 2 3890
3 0.99 0.002 1 2303
4 0.99 0.002 3 4204
| Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 | | Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 |
---|
λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 |
0.0001 | 16095 | 29943 | 42791 | 23026 | 38897 | 53225 | 29958 | 47439 | 62960 | 46052 | 66389 | 84062 | 0.0002 | 8048 | 14972 | 21396 | 11513 | 19450 | 26612 | 14979 | 23721 | 31479 | 23026 | 33187 | 42032 |
0.0003 | 5365 | 9982 | 14264 | 7676 | 12966 | 17741 | 9986 | 15813 | 20987 | 15351 | 22126 | 28022 | 0.0004 | 4024 | 7486 | 10698 | 5757 | 9725 | 13306 | 7490 | 11860 | 15740 | 11513 | 16595 | 21017 |
0.0005 | 3219 | 5989 | 8559 | 4606 | 7780 | 10645 | 5992 | 9489 | 12592 | 9211 | 13276 | 16814 | 0.0006 | 2683 | 4991 | 7132 | 3838 | 6483 | 8871 | 4993 | 7907 | 10493 | 7676 | 11064 | 14012 |
0.0007 | 2300 | 4278 | 6113 | 3290 | 5557 | 7604 | 4280 | 6778 | 8995 | 6579 | 9484 | 12007 | 0.0008 | 2012 | 3743 | 5349 | 2879 | 4863 | 6653 | 3745 | 5930 | 7871 | 5757 | 8299 | 10507 |
0.0009 | 1789 | 3328 | 4755 | 2559 | 4322 | 5914 | 3329 | 5271 | 6996 | 5117 | 7377 | 9340 | 0.0010 | 1610 | 2995 | 4280 | 2303 | 3890 | 5323 | 2996 | 4744 | 6296 | 4606 | 6639 | 8406 |
0.0011 | 1464 | 2723 | 3890 | 2094 | 3537 | 4839 | 2724 | 4313 | 5724 | 4187 | 6036 | 7642 | 0.0012 | 1342 | 2496 | 3566 | 1919 | 3242 | 4436 | 2497 | 3954 | 5247 | 3838 | 5533 | 7005 |
0.0013 | 1239 | 2304 | 3292 | 1772 | 2993 | 4094 | 2305 | 3650 | 4843 | 3543 | 5106 | 6467 | 0.0014 | 1150 | 2139 | 3057 | 1645 | 2779 | 3802 | 2140 | 3389 | 4498 | 3290 | 4742 | 6005 |
0.0015 | 1073 | 1997 | 2853 | 1536 | 2594 | 3549 | 1998 | 3163 | 4198 | 3071 | 4426 | 5605 | 0.0016 | 1006 | 1872 | 2675 | 1440 | 2432 | 3327 | 1873 | 2966 | 3935 | 2879 | 4149 | 5255 |
0.0017 | 947 | 1762 | 2518 | 1355 | 2289 | 3131 | 1763 | 2791 | 3704 | 2709 | 3906 | 4946 | 0.0018 | 895 | 1664 | 2378 | 1280 | 2161 | 2957 | 1665 | 2636 | 3498 | 2559 | 3689 | 4671 |
0.0019 | 848 | 1576 | 2253 | 1212 | 2048 | 2802 | 1577 | 2497 | 3314 | 2424 | 3495 | 4425 | 0.0020 | 805 | 1498 | 2140 | 1152 | 1945 | 2662 | 1498 | 2372 | 3148 | 2303 | 3319 | 4203 |
0.0021 | 767 | 1426 | 2038 | 1097 | 1853 | 2535 | 1427 | 2259 | 2999 | 2193 | 3161 | 4003 | 0.0022 | 732 | 1362 | 1946 | 1047 | 1769 | 2420 | 1362 | 2157 | 2862 | 2094 | 3018 | 3821 |
0.0023 | 700 | 1302 | 1861 | 1002 | 1692 | 2314 | 1303 | 2063 | 2738 | 2003 | 2887 | 3655 | 0.0024 | 671 | 1248 | 1783 | 960 | 1621 | 2218 | 1249 | 1977 | 2624 | 1919 | 2766 | 3503 |
0.0025 | 644 | 1198 | 1712 | 922 | 1556 | 2129 | 1199 | 1898 | 2519 | 1843 | 2656 | 3363 | 0.0026 | 620 | 1152 | 1646 | 886 | 1497 | 2048 | 1153 | 1825 | 2422 | 1772 | 2554 | 3234 |
0.0027 | 597 | 1110 | 1585 | 853 | 1441 | 1972 | 1110 | 1757 | 2332 | 1706 | 2459 | 3114 | 0.0028 | 575 | 1070 | 1529 | 823 | 1390 | 1901 | 1070 | 1695 | 2249 | 1645 | 2372 | 3003 |
0.0029 | 555 | 1033 | 1476 | 794 | 1342 | 1836 | 1034 | 1636 | 2172 | 1588 | 2290 | 2899 | 0.0030 | 537 | 999 | 1427 | 768 | 1297 | 1775 | 999 | 1582 | 2099 | 1536 | 2214 | 2803 |
0.0031 | 520 | 966 | 1381 | 743 | 1255 | 1717 | 967 | 1531 | 2031 | 1486 | 2142 | 2712 | 0.0032 | 503 | 936 | 1338 | 720 | 1216 | 1664 | 937 | 1483 | 1968 | 1440 | 2075 | 2628 |
0.0033 | 488 | 908 | 1297 | 698 | 1179 | 1613 | 908 | 1438 | 1908 | 1396 | 2012 | 2548 | 0.0034 | 474 | 881 | 1259 | 678 | 1145 | 1566 | 882 | 1396 | 1852 | 1355 | 1953 | 2473 |
0.0035 | 460 | 856 | 1223 | 658 | 1112 | 1521 | 856 | 1356 | 1799 | 1316 | 1897 | 2402 | 0.0036 | 448 | 832 | 1189 | 640 | 1081 | 1479 | 833 | 1318 | 1749 | 1280 | 1845 | 2335 |
0.0037 | 435 | 810 | 1157 | 623 | 1052 | 1439 | 810 | 1283 | 1702 | 1245 | 1794 | 2272 | 0.0038 | 424 | 788 | 1127 | 606 | 1024 | 1401 | 789 | 1249 | 1657 | 1212 | 1747 | 2213 |
0.0039 | 413 | 768 | 1098 | 591 | 998 | 1365 | 769 | 1217 | 1615 | 1181 | 1702 | 2156 | 0.0040 | 403 | 749 | 1070 | 576 | 973 | 1331 | 749 | 1186 | 1574 | 1152 | 1660 | 2102 |
|
| Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 | | Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 |
---|
λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 |
0.0041 | 393 | 731 | 1044 | 562 | 949 | 1299 | 731 | 1158 | 1536 | 1124 | 1620 | 2051 | 0.0042 | 384 | 713 | 1019 | 549 | 927 | 1268 | 714 | 1130 | 1500 | 1097 | 1581 | 2002 |
0.0043 | 375 | 697 | 996 | 536 | 905 | 1238 | 697 | 1104 | 1465 | 1071 | 1544 | 1956 | 0.0044 | 366 | 681 | 973 | 524 | 885 | 1210 | 681 | 1079 | 1431 | 1047 | 1509 | 1911 |
0.0045 | 358 | 666 | 951 | 512 | 865 | 1183 | 666 | 1055 | 1400 | 1024 | 1476 | 1869 | 0.0046 | 350 | 651 | 931 | 501 | 846 | 1158 | 652 | 1032 | 1369 | 1002 | 1444 | 1828 |
0.0047 | 343 | 638 | 911 | 490 | 828 | 1133 | 638 | 1010 | 1340 | 980 | 1413 | 1789 | 0.0048 | 336 | 624 | 892 | 480 | 811 | 1109 | 625 | 989 | 1312 | 960 | 1384 | 1752 |
0.0049 | 329 | 612 | 874 | 470 | 794 | 1087 | 612 | 969 | 1285 | 940 | 1355 | 1716 | 0.0050 | 322 | 599 | 856 | 461 | 778 | 1065 | 600 | 949 | 1260 | 922 | 1328 | 1682 |
0.0051 | 316 | 588 | 840 | 452 | 763 | 1044 | 588 | 931 | 1235 | 903 | 1302 | 1649 | 0.0052 | 310 | 576 | 823 | 443 | 749 | 1024 | 577 | 913 | 1211 | 886 | 1277 | 1617 |
0.0053 | 304 | 565 | 808 | 435 | 734 | 1005 | 566 | 896 | 1188 | 869 | 1253 | 1587 | 0.0054 | 299 | 555 | 793 | 427 | 721 | 986 | 555 | 879 | 1166 | 853 | 1230 | 1557 |
0.0055 | 293 | 545 | 779 | 419 | 708 | 968 | 545 | 863 | 1145 | 838 | 1207 | 1529 | 0.0056 | 288 | 535 | 765 | 412 | 695 | 951 | 535 | 848 | 1125 | 823 | 1186 | 1502 |
0.0057 | 283 | 526 | 751 | 404 | 683 | 934 | 526 | 833 | 1105 | 808 | 1165 | 1475 | 0.0058 | 278 | 517 | 738 | 397 | 671 | 918 | 517 | 818 | 1086 | 794 | 1145 | 1450 |
0.0059 | 273 | 508 | 726 | 391 | 660 | 903 | 508 | 805 | 1068 | 781 | 1126 | 1425 | 0.0060 | 269 | 500 | 714 | 384 | 649 | 888 | 500 | 791 | 1050 | 768 | 1107 | 1401 |
0.0061 | 264 | 491 | 702 | 378 | 638 | 873 | 492 | 778 | 1033 | 755 | 1089 | 1378 | 0.0062 | 260 | 483 | 691 | 372 | 628 | 859 | 484 | 766 | 1016 | 743 | 1071 | 1356 |
0.0063 | 256 | 476 | 680 | 366 | 618 | 845 | 476 | 754 | 1000 | 731 | 1054 | 1335 | 0.0064 | 252 | 468 | 669 | 360 | 608 | 832 | 469 | 742 | 984 | 720 | 1038 | 1314 |
0.0065 | 248 | 461 | 659 | 355 | 599 | 819 | 461 | 730 | 969 | 709 | 1022 | 1294 | 0.0066 | 244 | 454 | 649 | 349 | 590 | 807 | 454 | 719 | 954 | 698 | 1006 | 1274 |
0.0067 | 241 | 447 | 639 | 344 | 581 | 795 | 448 | 709 | 940 | 688 | 991 | 1255 | 0.0068 | 237 | 441 | 630 | 339 | 573 | 783 | 441 | 698 | 926 | 678 | 977 | 1237 |
0.0069 | 234 | 434 | 621 | 334 | 564 | 772 | 435 | 688 | 913 | 668 | 963 | 1219 | 0.0070 | 230 | 428 | 612 | 329 | 556 | 761 | 428 | 678 | 900 | 658 | 949 | 1201 |
0.0071 | 227 | 422 | 603 | 325 | 548 | 750 | 422 | 669 | 887 | 649 | 936 | 1185 | 0.0072 | 224 | 416 | 595 | 320 | 541 | 740 | 417 | 659 | 875 | 640 | 923 | 1168 |
0.0073 | 221 | 411 | 587 | 316 | 533 | 730 | 411 | 650 | 863 | 631 | 910 | 1152 | 0.0074 | 218 | 405 | 579 | 312 | 526 | 720 | 405 | 642 | 851 | 623 | 897 | 1136 |
0.0075 | 215 | 400 | 571 | 308 | 519 | 710 | 400 | 633 | 840 | 615 | 886 | 1121 | 0.0076 | 212 | 394 | 564 | 303 | 512 | 701 | 395 | 625 | 829 | 606 | 874 | 1106 |
0.0077 | 210 | 389 | 556 | 300 | 506 | 692 | 390 | 617 | 818 | 599 | 863 | 1092 | 0.0078 | 207 | 384 | 549 | 296 | 499 | 683 | 385 | 609 | 808 | 591 | 852 | 1078 |
0.0079 | 204 | 380 | 542 | 292 | 493 | 674 | 380 | 601 | 797 | 583 | 841 | 1065 | 0.0080 | 202 | 375 | 535 | 288 | 487 | 666 | 375 | 593 | 787 | 576 | 830 | 1051 |
|
| Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 | | Power=0.8 | Power=0.9 | Power=0.95 | Power=0.99 |
---|
λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | λ | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 | r=1 | r=2 | r=3 |
0.0081 | 199 | 370 | 529 | 285 | 481 | 658 | 370 | 586 | 778 | 569 | 820 | 1038 | 0.0082 | 197 | 366 | 522 | 281 | 475 | 650 | 366 | 579 | 768 | 562 | 810 | 1026 |
0.0083 | 194 | 361 | 516 | 278 | 469 | 642 | 361 | 572 | 759 | 555 | 800 | 1013 | 0.0084 | 192 | 357 | 510 | 275 | 464 | 634 | 357 | 565 | 750 | 549 | 791 | 1001 |
0.0085 | 190 | 353 | 504 | 271 | 458 | 627 | 353 | 559 | 741 | 542 | 781 | 990 | 0.0086 | 188 | 349 | 498 | 268 | 453 | 619 | 349 | 552 | 733 | 536 | 772 | 978 |
0.0087 | 185 | 345 | 492 | 265 | 448 | 612 | 345 | 546 | 724 | 530 | 764 | 967 | 0.0088 | 183 | 341 | 487 | 262 | 443 | 605 | 341 | 540 | 716 | 524 | 755 | 956 |
0.0089 | 181 | 337 | 481 | 259 | 438 | 599 | 337 | 533 | 708 | 518 | 746 | 945 | 0.0090 | 179 | 333 | 476 | 256 | 433 | 592 | 333 | 528 | 700 | 512 | 738 | 934 |
0.0091 | 177 | 330 | 471 | 254 | 428 | 585 | 330 | 522 | 692 | 507 | 730 | 924 | 0.0092 | 175 | 326 | 466 | 251 | 423 | 579 | 326 | 516 | 685 | 501 | 722 | 914 |
0.0093 | 174 | 322 | 461 | 248 | 419 | 573 | 323 | 511 | 677 | 496 | 714 | 904 | 0.0094 | 172 | 319 | 456 | 245 | 414 | 567 | 319 | 505 | 670 | 490 | 707 | 895 |
0.0095 | 170 | 316 | 451 | 243 | 410 | 561 | 316 | 500 | 663 | 485 | 699 | 885 | 0.0096 | 168 | 312 | 446 | 240 | 406 | 555 | 313 | 495 | 656 | 480 | 692 | 876 |
0.0097 | 166 | 309 | 442 | 238 | 402 | 549 | 309 | 490 | 650 | 475 | 685 | 867 | 0.0098 | 165 | 306 | 437 | 235 | 397 | 544 | 306 | 485 | 643 | 470 | 678 | 858 |
0.0099 | 163 | 303 | 433 | 233 | 393 | 538 | 303 | 480 | 636 | 466 | 671 | 850 | 0.0100 | 161 | 300 | 428 | 231 | 389 | 533 | 300 | 475 | 630 | 461 | 664 | 841 |
Contents of E:4
Contents of F:5
Contents of G:6
|