Cell#1 Program Instructions. Don’t run.

10
Cell#1 Program Instructions. Don’t run. In[1]:= Statistics`NormalDistribution` Used to load a Statistical Package Cell #3 In[2]:= ndist1 NormalDistribution 0, 1 ; phi x_ PDF ndist1, x Phi x_ CDF ndist1, x O ut[3]= x 2 2 2 General::spell1 : Possible spelling error: new symbol name "Phi" is similar to existing symbol "phi". O ut[4]= 1 2 1 Erf x 2 Defines standard normal pdf and cdf functions Ignore spelling warning Cell#2

description

Cell#1 Program Instructions. Don’t run. Cell#2. Used to load a Statistical Package. Cell #3. Defines standard normal pdf and cdf functions. Ignore spelling warning. Cell #4 - PowerPoint PPT Presentation

Transcript of Cell#1 Program Instructions. Don’t run.

Page 1: Cell#1 Program Instructions.  Don’t run.

Cell#1

Program Instructions. Don’t run.

In[1]:= Statistics NormalDistributionUsed to load a Statistical Package

Cell #3

In[2]:= ndist1 NormalDistribution0, 1;phix_ PDFndist1, xPhix_ CDFndist1, x

Out[3]=x

222

General::spell1: Possible spelling error:

new symbol name "Phi" is similar to existing symbol "phi".

Out[4]=1

2

1 Erfx2

Defines standard normal pdf and cdf functions

Ignore spelling warning

Cell#2

Page 2: Cell#1 Program Instructions.  Don’t run.

Clears, d, n0, nA, nB, x1, x2, y, y0, zbar, W, TfW_, d_ phiW n0nA nBdn0 nA nBs^2n0nA nBn0nA nBs^2

PhinA s^2 W nA nBT x2nBnA nBs n0nAnBs2 dn0nAnBn0nAnBs2 W2

2n0nAnB 1 ErfnAs2WnAnBTx22nBnAnBs 22

Cell #4Clears existing values of variables that may have been used in other programs. Then defines a function that is proportional to the pdf of W and depends on ∆, f ( W, d ) where ∆ is defined by the variable d.

Page 3: Cell#1 Program Instructions.  Don’t run.

n0 200;

nA 100;

nB 100;

s 10;

x1 1.8881;

x2 0.9216;

y 0.7888;

y0 0.4956;

zbarnAx1nBynA nB;Wobs n0nAnBzbarn0 nA nBs^2 n0nA nBy0n0 nAnBs^2TnA nBzbarn0 nA nB n0y0n0 nA nB1.83405

0.421425

Cell #5Defines actual values from relevant clinical data and parameters of interest. σ is set by s.

Page 4: Cell#1 Program Instructions.  Don’t run.

ud zbar y0

ain0nAnBn0 nAnBs2 ud4

n0nA nBn0 nA nBs 1nA nB

1n0

bin0nAnBn0 nAnBs2 ud4

n0nA nBn0 nA nBs 1nA nB

1n0

Cell#6

Defines the initial values for the endpoints of the integral, a & b.

Page 5: Cell#1 Program Instructions.  Don’t run.

a ai

b bi

PlotfW, ud,W, a, b2.16595

5.83405

-2 2 4 6

0.05

0.1

0.15

0.2

0.25

0.3

Graphics

Cell #7Creates a plot of the distribution of W on [a, b]. If the plot indicates that the interval is not wide enough, values of a & b need to be manually set (trial and error) so that most of the distribution is captured before proceeding with additional Cells.

Page 6: Cell#1 Program Instructions.  Don’t run.

lower y y0 3s1nB 1n0

upper y y0 3s1nB 1n0 Cell#8

Defines a range of values for ∆ likely to contain the confidence interval of interest.

ntot 60

incupper lowerntotdtb Tableu,u, lower, upper, inc;

Cell #9

Establishes the total number of points to determine the values of

FQ( Wobs | X*, ∆ ) as a function of ∆.

dtb is a tabulation of values for ∆ at which FQ( Wobs | X*, ∆ ) is calculated.

Page 7: Cell#1 Program Instructions.  Don’t run.

c1

TableNIntegrateft, u,t, n0nA nBn0nA nBs2 ub a,n0nAnBn0 nAnBs2 ub a,u, lower, upper, inc

Cell #10

c1 is a tabulation of the reciprocal of normalization constants, which depend on the values of ∆ (symbolically represented by u).

a1 TableNIntegrateft, u,t, n0nA nBn0nA nBs2 ub a, Wobs,u, lower, upper, inc

Cell #11

a1 is a tabulation by u (which symbolically represents ∆) of the area under the curve of f ( t , u ) for fixed u and over t on [ – Infinity, Wobs ]. For practical purposes, the lower limit of the integral is specified as:

n0(nA+nB)/((n0+nA+nB)s2)u – (b – a).

Page 8: Cell#1 Program Instructions.  Don’t run.

p1 a1c1Cell #12

p1 provides a tabulation of FQ( Wobs | X*, ∆ ) by ∆.

tb Transposedtb, p1;Cell #13

This cell associates each value of FQ( Wobs | X*, ∆ ) with the corresponding value of ∆.

fu InterpolationtbCell #14

An interpolating function is then set to the values listed in tb.

Page 9: Cell#1 Program Instructions.  Don’t run.

Plotfuu,u, lower, upper, PlotRange 0, 1

-2 -1 1 2 3 4 5

0.2

0.4

0.6

0.8

1

Graphics

Cell #15

A plot of the interpolating function is produced. The plot should show a reverse ‘S’ curve decreasing from near 1 to near 0. If this plot is not obtained, values of ‘upper’ and ‘lower’ (Cell 8) need to be set by the user by trial and error until the desired curve is obtained.

Page 10: Cell#1 Program Instructions.  Don’t run.

FindRootfuu 0.975,u,upper lower2u 0.742163Cell #16

The lower bound of the confidence interval is solved by finding ∆ such that FQ( Wobs | X*, ∆ ) = 1 – α / 2. In the example provided, it is – 0.7422.

FindRootfuu 0.025,u,upper lower2u 3.61112Cell #17

The upper bound of the confidence interval is solved by finding ∆ such that FQ( Wobs | X*, ∆ ) = α / 2. In the example provided, it is 3.6111.