REVO2700 stkCalcZP --The following Transcript functions are for calculating normal and --chi-square probabilities and critical values. These were adapted by --Alistair Campbell, Dept of Psychology, James Cook University, Townsville, Australia --from John Walker's (http://www.fourmilab.ch/rpkp/experiments/analysis/zCalc.html?) --Javascript functions based on C implementations written by Gary Perlman --of Wang Institute, Tyngsboro, MA 01879. Both the original C code, the JavaScript and --this Transcript code are in the public domain. -- on openStack global Z_MAX, Z_EPSILON put "6" into Z_MAX put "0.0000001" into Z_EPSILON end openStack --Function to calculate Pr(Q) given a z-Score function calc_q val if abs(val) < 0 or abs(val) > 1 then return "**Error**" else return abs(critz(val)) end if end calc_q --Function to calculate a z-Score given Pr(Q) function calc_z val global Z_MAX if val <-Z_MAX then return 0 else if val > Z_MAX then return 1 else put poz(val) into qz --put 1-qz into qz return qz end if end calc_z --CRITZ -- Compute critical normal z value to -- produce given p. We just do a bisection -- search for a value within CHI_EPSILON, -- relying on the monotonicity of pochisq(). function critz p global Z_MAX, Z_EPSILON,minz, maxz, zval, pval -- local Z_EPSILON = 0.000001 -- local zval = 0.0 -- local pval -- put -Z_MAX into minz -- put Z_MAX into maxz put "0.000001" into Z_EPSILON put "0.0" into zval if p < 0 or p > 1 then return -1 end if repeat while (maxz-minz)> Z_EPSILON put poz(zval) into pval if pval > p then put zval into minz else put zval into maxz end if put (maxz + minz)*0.5 into zval end repeat return zval end critz --POZ -- probability of normal z value -- Adapted from a polynomial approximation in: -- Ibbetson D, Algorithm 209 -- Collected Algorithms of the CACM 1963 p. 616 -- Note: -- This routine has six digit accuracy, so it is only useful for absolute -- z values <= 6. For z values > to 6.0, poz() returns 0.0. -- function poz z global Z_MAX local y, x, w if z=0 then put 0 into x else put abs(z)*0.5 into y -- put z*0.5 into y if y>(Z_MAX*0.5) then put 1 into x else if y<1 then put y*y into w put ((((((((0.000124818987 * w \ - 0.001075204047) * w + 0.005198775019) * w \ - 0.019198292004) * w + 0.059054035642) * w \ - 0.151968751364) * w + 0.319152932694) * w \ - 0.531923007300) * w + 0.797884560593) * y * 2.0 \ into x else put y-2 into y put (((((((((((((-0.000045255659 * y + 0.000152529290) * y - 0.000019538132) * y - 0.000676904986) * y + \ 0.001390604284) * y - 0.000794620820) * y - 0.002034254874) * y + 0.006549791214) * y - 0.010557625006) * y + \ 0.011630447319) * y - 0.009279453341) * y + 0.005353579108) * y - 0.002141268741) * y + 0.000535310849) * y + \ 0.999936657524 into x end if end if if z < 0 then return ((x + 1)*0.5) else return ((1 - x)*0.5) end if end poz 8Az-Score Calculation  UTahoma cRevOnlineid365 cREVGeneralscripteditorvscroll138breakpointconditionsscripteditorselection629 breakpointsbreakpointstatesstackfileversion2.7AlreadyHiddenfalsecREVGeometryCachestackID1019 @A cREVGeneralscripteditorvscroll0scripteditorselection0cREVGeometryCacheIDs 12536242310271007125362423102810081253624241892101112536242511461014125362424189310121253624256086101612536242369631009125362418965810061253624236964101012536241831011004cREVGeometrycacheorder total10 fldz)`JB cREVGeneral revUniqueID 1253624183101  1.9  Label Field  > cREVTable currentviewz-Score: cREVGeneral revUniqueID 1253624189658 z-Score: fldq1)`B cREVGeneral revUniqueID 1253624231027  .05  Label Field > cREVTable currentviewPr(Q): cREVGeneral revUniqueID 1253624231028 Pr(Q): fldq)`JLB cREVGeneral revUniqueID 1253624236963  0.0287  Label Field K> cREVTable currentviewPr(Q): cREVGeneral revUniqueID 1253624236964 Pr(Q): fldz1)`JB cREVGeneral revUniqueID 1253624241892  1.6449  Label Field I> cREVTable currentviewz-Score cREVGeneral revUniqueID 1253624241893 z-Scorebtnzqepjon mouseUp put fld "fldz" into myZscore put round(calc_z (myZscore),4) into fld "fldq" end mouseUp B,R0z to Q cREVGeneralscripteditorvscroll0 revUniqueID 1253624251146scripteditorselection76 btnqzepglobal Z_MAX,minz, maxz, zval, pval on mouseUp global Z_MAX,minz, maxz, zval, pval, Z_EPSILON -- initialise some variables put 6 into Z_MAX put 0.0000001 into Z_EPSILON put -Z_MAX into minz put Z_MAX into maxz put 0 into zval put 0 into pval -- do the calculations put fld "fldq1" into myQval put round(calc_q (myQval),4) into fld "fldz1" end mouseUp *R6Q to z cREVGeneralscripteditorvscroll0 revUniqueID 1253624256086scripteditorselection97 revOnline | RunRev