Cell #1
description
Transcript of Cell #1
This Program is used with DTL designs in the normal distribution setting. It is used to find p-values and critical values for hypothesis tests of the true mean of the selected treatment.
Cell #1
Program instructions, don’t run
Cell #2
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
In[5]:= ClearnA, nB, u10, s, x2, z, ffz_ phiznA nBu10nA nB sPhinA znA nBx2nBnAnBs
Out[6]=
nAnBu10z2
2nAnBs2 1 ErfnAnAnBx2z2nBnAnBs22
Cell #4
Cell #4
Clears existing values of variables that may have been used in other programs. Then defines function that is proportional to the pdf of Z.
In[7]:= nA 100;
nB 100;
u10 0;
s 10;
x1 1.8881;
x2 0.9216;
y 0.7888;
zobs nAx1nBy
Out[14]= 267.69
In[15]:= ai NnA nBu10 4nA nB sbi NnA nBu10 5nA nB s
Out[15]= 565.685
Out[16]= 707.107
Cell #5
Defines actual values from relevant clinical data and parameters of interest. μ10 is set by u10 and σ is set by s.
Cell #6
Defines the initial values for the endpoints of the integral, a & b.
In[17]:= a ai
b bi
Plotfz,z, a, bOut[17]= 565.685
Out[18]= 707.107
-400 -200 200 400 600
0.02
0.04
0.06
0.08
Out[19]= Graphics
Cell #7
Creates a plot of the distribution of Z 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.
Make sure most of the distribution is captured.
In[20]:= cN NIntegratefz,z, a, bpz_ fzcN
Out[20]= 25.2251
Out[21]= 0.00790765 z2400001 Erf1
200184.32 z
Cell#8
Finds the normalization constant, (1/cN), and defines the pdf of Z, p[z].
In[22]:= Pz_ NIntegratept,t, a, zNIntegrate::nlim: t z is not a valid limit of integration.
NIntegrate::nlim: t z is not a valid limit of integration.
Out[22]= NIntegratept,t, a, z
Cell #9
Defines the cdf of Z, P[z]. The warnings can be ignored in version 4.
In[23]:= zguessa b2;FindRootPz 0.95,z, zguessNIntegrate::nlim: t z is not a valid limit of integration.
NIntegrate::nlim: t z is not a valid limit of integration.
NIntegrate::nlim: t z is not a valid limit of integration.
General::stop:
Further output of NIntegrate::nlim will be suppressed during this calculation.
Out[24]=z 329.779
Cell #10
This cell finds the qth quantile of the distribution, i.e. finds z such that
P[z] = q. In the example below, the 95th percentile of the distribution is found to be 329.779. This typically would be the 5% critical value for a one-sided alternative hypothesis, e.g. HA: μ10 > 0.
In[25]:= pvalue1 NIntegratepz,z, zobs, bpvalue2 1 pvalue1
pvalue3 2 Minpvalue1, pvalue2Out[25]= 0.134478
Out[26]= 0.865522
Out[27]= 0.268956
Cell #11
Finds the various p-values that are typically of interest to researchers