MTB > # Solution to Exercise 23 (STAT 657, Fall 2008, Fall 2010, & Fall 2012) MTB > MTB > # I'll put the size of the sign test in k1, and the power of the sign test MTB > # against the alternative -0.1 in k2. MTB > cdf 43 k1; SUBC> bino 100 0.5. MTB > name k1 'signsize' k2 'signpow' MTB > print k1 signsize 0.0966740 MTB > # For the case of mu = -0.1, I'll put P( X_i > 0 ) in k3. MTB > name k3 'prob' MTB > cdf 0 k3; SUBC> norm -0.1 1. MTB > let k3 = 1 - k3 MTB > print k3 prob 0.460172 MTB > cdf 43 k2; SUBC> bino 100 k3. MTB > print k2 signpow 0.307577 MTB > # Letting alpha be the size of the sign test, I'll put -z_alpha in k4. MTB > invcdf k1 k4; SUBC> norm 0 1. MTB > name k4 '-z_alpha' MTB > print k4 -z_alpha -1.30074 MTB > # It follows from near the top of p. 5-10 of the class notes that MTB > # k2 = Phi( k4 -sqrt(n)*eta ) = Phi( k4 + sqrt(n)/10 ), MTB > # from which it follows that MTB > # Phi^{-1}(k2) = k4 + sqrt(n)/10, MTB > # or equivalently, MTB > # sqrt(n) = 10[ Phi^{-1}(k2) - k4 ]. MTB > # I'll solve the above for n and put the value in k5. MTB > invcdf k2 k5; SUBC> norm 0 1. MTB > let k5 = 10*( k5 - k4 ) MTB > let k5 = k5*k5 MTB > name k5 'n' MTB > print k5 n 63.6818 MTB > # This is very close to the value 63.6620 which results from using the sample MTB > # size suggested by the A.R.E. of the sign test w.r.t. the z test when the MTB > # underlying distribution is norml. (The A.R.E. is 2/pi, or about 0.636620.) MTB > # As a check that 64 is the best choice for a sample size, I'll put the power MTB > # of the z test for various sample sizes (63, 64, and 65) in k6 through k8, MTB > # and compare these power values against the power of the specified sign test. MTB > let k16 = k4 + sqrt(63)/10 MTB > let k17 = k4 + sqrt(64)/10 MTB > let k18 = k4 + sqrt(65)/10 MTB > cdf k16 k6; SUBC> norm 0 1. MTB > cdf k17 k7; SUBC> norm 0 1. MTB > cdf k18 k8; SUBC> norm 0 1. MTB > name k6 'zpow_n63' k7 'zpow_n64' k8 'zpow_n65' MTB > print k2 k6-k8 signpow 0.307577 zpow_n63 0.306073 zpow_n64 0.308278 zpow_n65 0.310472 MTB > # Using n = 64 results in the power being closest to the power of the sign test.