![]() | Content Disclaimer Copyright @2020. All Rights Reserved. |
Links : Home Index (Subjects) Contact StatsToDo |
Explanations
Javascript Programs
R Codes
Tables
E
F
GIntroductionIn prediction statistics, the rates (True Positive Rate (TPR), False Positive Rate (FPR), False Negative Rate (FNR), and True Negative Rate (TNR) are proportions that follow the binomial distribution. Estimation of sample size requirements for estimating and comparing these rates can therefore be the same as those for proportions.On this page however, the sample size estimations for these proportions are modified to suit the needs of the prediction environment, and they are as follows Sample size for a Single GroupThis estimats sample size requirements to establish the True Positive Rate (TPR) or True Negative Rate (TNR). To be useful, these rates must be significantly >0.5, so the Fleming's Procedure is used. The parameters are
Please Note: If required, the sample size for False Positev Rate (FPR = 1 - TNR) is the same as that for True Negative Rate (TNR), and for False Negative Rate (FNR = 1 - TPR) the same as that for True Positve Rate (TPR) Sample Size for comparing rates from two groupsAs prediction rates (TPR, FPR, FNR, TNR) are essentially proportions, they can be compared as such, and the sample size for their comparisons can be the same as sample size for comparing two proportionsMore recently Casagrande et.al. suggested an improved sample size calculation that provides greater precision, which allows both paired and unpaired comparisons. This algorithm is presented on this page. Unpaired comparisons is used to compare two groups of unrelated individuals. An example may be to compare the True Positive Rate (TPR) of the mother feeling decreased fetal movement as a predictor of impending stillbirth between one group with first pregnancies and another group who had a baby before. The sample size calculated is the number of subjects that are outcome positive (OPos, stillbirths in this case) needed in each of the groups. Paired comparisons is used to compare two tests or predictors, when both are administered to the same individual to predict the same outcome. An example is to compare the True Positive Rates (TPR) of the mother feeling decreased fetal movement, and that of an ultrasound detection of abnormal blood flow pattern, as predictors of impending stillbirth. The pair of tests can be administered to the same pregnant woman, and the qualities of the tests compared against the outcome. Paired comparison is very much more powerful, as it reduces or eliminates variations between individuals. The sample size required pertains to the number of subjects that received both tests and are outcome positive, the number of matched pairs. Two sample sizes are calculated for paired comparisons, the minimum and the maximum. In theory, the correct sample size is somewhere between the minimum and the maximum, depending on the correlation (agreeing with each other) between the tests. In practice, a conclusion that a statistically significant difference exists can be drawn if this is demonstrated when the sample size reaches or exceeds the minimum, but a conclusion that there is no significant difference can only be drawn after the maximum sample size has been reached. The sample size using Casagrande's algorithm is based on the two tail mode ReferencesMachin D, Campbell M, Fayers, P, Pinol A (1997) Sample Size Tables for Clinical Studies. Second Ed. Blackwell Science IBSN 0-86542-870-0 p. 18-20, p. 254-255 Beam, C. A. (1992), "Strategies for Improving Power in Diagnostic Radiology Research," American Journal of Radiology, 159, 631-637. Casagrande, J. T., Pike, M. C., and Smith, P. G. (1978), "An Improved Approximate Formula for Calculating Sample Sizes for Comparing Two Binomial Distributions," Biometrics, 34, 483-486.
Program 1: Sample size for Single Group to Estimate TPR or TNR
# Pgm1: Single geoup TPR or TNR > 0.5 #Note: Rate must be >0.5 myDat = (" Alpha Power Rate 0.05 0.8 0.55 0.01 0.8 0.60 0.01 0.95 0.85 ") myDat df <- read.table(textConnection(myDat),header=TRUE) # conversion to data frame df # display input data (true positive, false positive, false negative, and true negative) SSiz <- vector() # sample size for(i in 1:nrow(df)) { za = qnorm(df$Alpha[i]) zb = qnorm(1 - df$Power[i]) pn = df$Rate[i] p0 = 0.5; top = za * sqrt(p0*(1-p0)) + zb * sqrt(pn*(1-pn)); bot = pn - p0; SSiz <- append(SSiz, ceiling((top*top) / (bot*bot))) } SSiz df$SSiz <- SSiz df # display data frame including calculated sample sizeThe results are > df # display data frame including calculated sample size Alpha Power Rate SSiz 1 0.05 0.80 0.55 617 2 0.01 0.80 0.60 249 3 0.01 0.95 0.85 26Program 2: Sample size for comparing rates (TPR, FPR, FNR, TNR) in two groups # Pgm2: SSiz comparing two rates myDat = (" Alpha Power Rate1 Rate2 0.05 0.8 0.8 0.7 0.01 0.8 0.8 0.7 0.05 0.9 0.8 0.7 0.01 0.9 0.8 0.7 ") myDat df <- read.table(textConnection(myDat),header=TRUE) # conversion to data frame df # display True Positive Rateate and False Positive Rate SSizU <- vector() # Sample Size per group for unpaired comparison SSizPMin <- vector() # Minimum Sample Size (pairs) for paired comparison SSizPMax <- vector() # Maximum Sample Size (pairs) for paired comparison for(i in 1:nrow(df)) { za = qnorm(df$Alpha[i]) zb = qnorm(1 - df$Power[i]) r1 = df$Rate1[i] r2 = df$Rate2[i] Phat = (r1 + r2) / 2.0 q1 = 1.0 - r1 q2 = 1.0 - r2 Qhat = (q1 + q2) / 2.0 a = za * sqrt(2.0 * Phat * Qhat) + zb * sqrt(r1 * q1 + r2 * q2) a = a * a dif = abs(r1-r2); SSizU <- append(SSizU, ceiling(a * (1 + sqrt(1 + 4 * dif / a))^2 / (4 * dif * dif))) phimax = r1 * (1 - r2) + r2 * (1 - r1); SSizPMin <- append(SSizPMin, ceiling((za * sqrt(dif) + zb * sqrt(dif - dif * dif))^2 / (dif * dif))) SSizPMax <- append(SSizPMax, ceiling((za * sqrt(phimax) + zb * sqrt(phimax - dif * dif))^2 / (dif * dif))) } df$SSizU <- SSizU df$SSizPMin <- SSizPMin df$SSizPMax <- SSizPMax df # display data frame plus sample sizes for unpairec xomparison, plus min and max of paired comparisonThe results are > df # display data frame plus sample sizes for unpairec xomparison, plus min and max of paired comparison Alpha Power Rate1 Rate2 SSizU SSizPMin SSizPMax 1 0.05 0.8 0.8 0.7 251 60 233 2 0.01 0.8 0.8 0.7 395 98 379 3 0.05 0.9 0.8 0.7 339 82 322 4 0.01 0.9 0.8 0.7 506 126 491
Sample Size for 1 Group
Sample Size for 2 Groups
Sample Size required for a True Positive Rate (TPR) or True Negative Rate (TNR) that is significantly greater than 0.5
r=rate(TPR or TNR) ssiz = sample size
Sample size for comparison between two True Positive (TPR, Sensitivity) or Negative (TNR, Specificity) Rates
α=Probability of Type I Error, β=Probability of Type II Error s1 and s2 are the TPR or TNR in the two groups being compared ssU = sample size per group in an unpaired comparison ssMin and ssMax are the minimum and maximum sample size (pairs) in a paired comparison
Contents of E:4
Contents of F:5
Contents of G:6
|