Dr. Hackney STA Solutions pg 172

Dr. Hackney STA Solutions pg 172 -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Second Edition 10-15 p 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 1 score . 99 . 93 . 97 . 92 . 90 . 89 . 90 . 92 . 97 . 93 . 99 cc . 99 . 99 . 97 . 92 . 98 . 98 . 98 . 92 . 97 . 99 . 99 Mathematica code to do the calculations is: Needs["Statistics‘Master‘"] Clear[p, x] pbino[p_, x_] = PDF[BinomialDistribution[n, p], x]; cut = 1.645^2; n = 10; The quadratic score interval with and without continuity correction slowcc[x_] := p /. FindRoot[(x/n - 1/(2*n) - p)^2 == cut*(p*((1 - p))/n, {p, .001}] supcc[x_] := p /. FindRoot[(x/n + 1/(2*n) - p)^2 == cut*(p*((1 - p)/n, {p, .999}] slow[x_] := p /. FindRoot[(x/n - p))^2 == cut*(p*(1 - p))/n, {p, .001}] sup[x_] := p /. FindRoot[(x/n - p)^2 == cut*(p*(1 - p)/n, {p, .999}] scoreintcc=Partition[Flatten[{{0,sup[0]},Table[{slowcc[i],supcc[i]}, {i,1,n-1}],{slowcc[n],1}},2],2]; scoreint=Partition[Flatten[{{0,sup[0]},Table[{slow[i],sup[i]}, {i,1,n-1}],{slowcc[n],1}},2],2]; Length Comparison Table[(sup[i] - slow[i])/(supcc[i] - slowcc[i]), {i, 0, n}] Now we’ll calculate coverage probabilities scoreindcc[p_,x_]:=If[scoreintcc[[x+1]][[1]]<=p<=scoreintcc[[x+1]][[2]],1,0]
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scorecovcc[p_]:=scorecovcc[p]=Sum[pbino[p,x]*scoreindcc[p,x],{x,0,n}] scoreind[p_,x_]:=If[scoreint[[x+1]][[1]]<=p<=scoreint[[x+1]][[2]],1,0] scorecov[p_]:=scorecov[p]=Sum[pbino[p,x]*scoreind[p,x],{x,0,n}] {scorecovcc[.0001],Table[scorecovcc[i/10],{i,1,9}],scorecovcc[.9999]}//N {scorecov[.0001],Table[scorecov[i/10],{i,1,9}],scorecov[.9999]}//N 10 . 47 a. Since 2 pY 2 nr (approximately) P ( 2 nr, 1-/ 2 2 pY 2 nr,/ 2 ) = 1-, and rearrangment gives the interval. b. The interval is of the form P ( a/ 2 Y p b/ 2 Y ), so the length is proportional to b-a . This must be minimized subject to the constraint R b a f ( y ) dy = 1- , where f ( y ) is the pdf of a 2 nr . Treating b as a function of a , dierentiating gives b-1 = 0 and f ( b ) b-f ( a ) = 0 which implies that we need f ( b ) = f ( a )....
View Full Document

This note was uploaded on 02/03/2012 for the course STA 1014 taught by Professor Dr.hackney during the Spring '12 term at UNF.

Ask a homework question - tutors are online