125
11
Computer CodePower Curves
This chapter describes computer codes and procedures for generating the
power curves for various tests. Each test (except Test 6.1, for which only R
code is presented) will have the following parts:
Input parameters
SAS code
JMP Data Table and formulas
R
Test 1.1 Single Binomial Proportion
(One-SidedProbability of “Success”)
Input parameters:
P0 = minimum desired probability of success
P1 = alternate values for probability of success (P1 ≤ P0)
N = sample size
Xc = critical value for number of successes (yields ~ 1 − beta probability of
rejecting the null hypothesis if probability of success = P
0
)
SAS code:
libname stuff 'H:\Personal Data\Equivalence & Noninferiority\
Programs & Output';
data calc;
set stuff.D20120730_One_Proportion_Power;
power = 1 - probbnml(P1,N,Xc-1);/* Pr{X > = Xc} */
run;
proc print data = calc;/*dataset calc has columns N, Xc, P0,
P1, power */
run;
126 Equivalence and Noninferiority Tests
Output:
The SAS System 09:04 Monday, July 30, 2012 1
Obs N Xc P0 P1 power
1 100 92 0.95 0.95 0.93691
2 100 92 0.95 0.94 0.85371
3 100 92 0.95 0.93 0.73397
4 100 92 0.95 0.92 0.59263
5 100 92 0.95 0.91 0.44940
6 100 92 0.95 0.90 0.32087
7 100 92 0.95 0.89 0.21651
8 100 92 0.95 0.88 0.13859
9 100 92 0.95 0.87 0.08448
10 100 92 0.95 0.86 0.04921
11 100 92 0.95 0.85 0.02748
12 100 92 0.95 0.84 0.01474
13 100 92 0.95 0.83 0.00762
14 100 92 0.95 0.82 0.00380
15 100 92 0.95 0.81 0.00183
16 100 92 0.95 0.80 0.00086
JMP Data Table and formulas:
Power for Test 1.1, JMP screen.
127Computer Code—Power Curves
Note that the column labeled “Power” is computed as described in the
formula view.
R:
> prob <- c(0.95,.94,.93,.92,.91,.90,.89,.88,.87,.86,.85,.84,
.83,.82,.81,.80)
> power <- 1 - pbinom(92,100,prob)
> power
[1] 0.8720395214 0.7483494398 0.5987792361 0.4471097512
0.3127949596
[6] 0.2060508618 0.1284536668 0.0761360984 0.0430807590
0.0233537817
[11] 0.0121651919 0.0061048616 0.0029577572 0.0013860090
0.0006291400
[16] 0.0002769869
> plot(prob,power)
0.80 0.85 0.90 0.95
0.0
0.2
0.4
0.6
0.8
Prob
Power
Test 1.1, R: power curve.
Test 2.1 Single Mean (One-Sided)
Input parameters:
muA = alternative values of the mean
muL = minimum desirable value for the mean
128 Equivalence and Noninferiority Tests
sigma = prior estimate of the standard deviation
n = sample size
SAS code:
libname stuff 'H:\Personal Data\Equivalence & Noninferiority\
Programs & Output';
data calc;
set stuff.d20120801_one_mean;
delta = (muA - muL)/sigma;
nc = sqrt(n) * delta;
tcrit = tinv(0.05,n-1);
power = 1 - probt(tcrit,n-1,nc);/* Pr{T' > = tcrit} */
run;
proc print data = calc;/*dataset calc has columns n muL muA
sigma delta nc power */
run;
The SAS System 09:11 Wednesday, August 1, 2012 1
Obs n muL muA sigma delta nc tcrit power
1 20 100 96.00 3.5 -1.14286 -5.11101 -1.72913 0.00053
2 20 100 96.25 3.5 -1.07143 -4.79157 -1.72913 0.00150
3 20 100 96.50 3.5 -1.00000 -4.47214 -1.72913 0.00390
4 20 100 96.75 3.5 -0.92857 -4.15270 -1.72913 0.00929
5 20 100 97.00 3.5 -0.85714 -3.83326 -1.72913 0.02033
6 20 100 97.25 3.5 -0.78571 -3.51382 -1.72913 0.04094
7 20 100 97.50 3.5 -0.71429 -3.19438 -1.72913 0.07597
8 20 100 97.75 3.5 -0.64286 -2.87494 -1.72913 0.13021
9 20 100 98.00 3.5 -0.57143 -2.55551 -1.72913 0.20668
10 20 100 98.25 3.5 -0.50000 -2.23607 -1.72913 0.30485
11 20 100 98.50 3.5 -0.42857 -1.91663 -1.72913 0.41961
12 20 100 98.75 3.5 -0.35714 -1.59719 -1.72913 0.54173
13 20 100 99.00 3.5 -0.28571 -1.27775 -1.72913 0.66005
14 20 100 99.25 3.5 -0.21429 -0.95831 -1.72913 0.76440
15 20 100 99.50 3.5 -0.14286 -0.63888 -1.72913 0.84815
16 20 100 99.75 3.5 -0.07143 -0.31944 -1.72913 0.90933
17 20 100 100.00 3.5 0.00000 0.00000 -1.72913 0.95000
18 20 100 100.25 3.5 0.07143 0.31944 -1.72913 0.97460
19 20 100 100.50 3.5 0.14286 0.63888 -1.72913 0.98814
20 20 100 100.75 3.5 0.21429 0.95831 -1.72913 0.99492
21 20 100 101.00 3.5 0.28571 1.27775 -1.72913 0.99800
129Computer Code—Power Curves
JMP Data Table and formulas:
Power for Test 2.1, JMP screen.
R:
> muA <- c(96,96.25,96.5,96.75,97,97.25,97.5,97.75,98,98.25,
98.5,98.75,99,99.25,99.5,99.75,100,100.25,100.5,100.75,101)
> muL <- 100
> n <- 20
> sigma <- 3.5
> delta <- (muA - muL)/sigma
> nc = sqrt(n)*delta
> tcrit <- qt(0.05,n-1)
> power <- 1 - pt(tcrit,n-1,nc)
> plot(delta,power)

Get Equivalence and Noninferiority Tests for Quality, Manufacturing and Test Engineers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.