|
| 1 | + |
| 2 | + SUBROUTINE IPRELRISK |
| 3 | + . (XALPHA,POWER,XP0,XN,XM,UORF,P1L,ODDSL,RL,P1H,ODDSH,RH) |
| 4 | +!MS$ATTRIBUTES REFERENCE :: P1L |
| 5 | +!MS$ATTRIBUTES REFERENCE :: ODDSL |
| 6 | +!MS$ATTRIBUTES REFERENCE :: RL |
| 7 | +!MS$ATTRIBUTES REFERENCE :: P1H |
| 8 | +!MS$ATTRIBUTES REFERENCE :: ODDSH |
| 9 | +!MS$ATTRIBUTES REFERENCE :: RH |
| 10 | + IMPLICIT NONE |
| 11 | + |
| 12 | + REAL*4 XALPHA,POWER,XP0,XN,XM,P1L,ODDSL,RL,P1H,ODDSH,RH |
| 13 | + INTEGER*4 UORF |
| 14 | +C |
| 15 | +C Relative risk CALCULATIONS FOR INDEPENDENT PROPORTIONS |
| 16 | +C DERIVE Relative risk FOR EACH GROUP IN A TRIAL OF TWO TREATMENTS |
| 17 | +C OR A CASE-CONTROL STUDY. |
| 18 | +C NORMAL APPROXIMATION ASSUMED |
| 19 | +C |
| 20 | +C Power formula from: Schlesselman: Case-control Studies: Design, |
| 21 | +C Conduct, Analysis. New York: Oxford U. Press 1982: 144-152. |
| 22 | +C See also: FRIEDMAN, FURBERG AND DEMETS: |
| 23 | +C FUNDAMENTALS OF CLINICAL TRIALS. BOSTON: WRIGHT PSG. 1982:75. |
| 24 | +C |
| 25 | +C INPUT: |
| 26 | +C ALPHA Type I error probability (two tailed) |
| 27 | +C POWER The desired statistical power |
| 28 | +C P0 True probability of exposure in control group when CASECTL=Y |
| 29 | +C True probability of event in control group when CASECTL=N |
| 30 | +C N Number of case patients |
| 31 | +C M Ratio of control to case |
| 32 | +C CASECTRL 1 for case-control studies |
| 33 | +C 2 for prospective studies |
| 34 | +C UORF =1 for uncorrected chi-square test |
| 35 | +C =2 for Fisher's exact test |
| 36 | +C OUTPUT: |
| 37 | +C RELRISK Relative risk of cases relative to controls that can be |
| 38 | +C detected with power POWER (when casectl=N) |
| 39 | +C ODDSRATIO Oddsratio of cases to controls that can be detected |
| 40 | +C with power POWER (when casectl=Y) |
| 41 | +C P1 True probability of exposure in case group that can be |
| 42 | +C detected with power POWER when CASECTL=Y |
| 43 | +C True probability of event in experimantal group that can |
| 44 | +C be detected with power POWER when CASECTL=N |
| 45 | +C |
| 46 | +C |
| 47 | +C Globals |
| 48 | +C |
| 49 | +C Declare variables in common to be made available to the function. |
| 50 | +C |
| 51 | + REAL ALPHA,BETA,P0,N,M,Q0,Q1 |
| 52 | + COMMON/IPCOM/ALPHA,BETA,P0,N,M,Q0,Q1 |
| 53 | +C |
| 54 | +C Declare functions. |
| 55 | +C |
| 56 | + EXTERNAL CHISQSIZE |
| 57 | + REAL CHISQSIZE |
| 58 | + EXTERNAL FISHERSIZ |
| 59 | + REAL FISHERSIZ |
| 60 | +C |
| 61 | +C Locals |
| 62 | +C |
| 63 | + INTEGER ERRORL,ERRORH |
| 64 | + REAL E1,EPS,Y1,Y2,Q1L,Q1H |
| 65 | +C |
| 66 | +C Code: |
| 67 | +C |
| 68 | + ALPHA=XALPHA |
| 69 | + BETA=1.-POWER |
| 70 | + P0=XP0 |
| 71 | + N=XN |
| 72 | + M=XM |
| 73 | +C |
| 74 | +C Set error tolerance values. |
| 75 | +C |
| 76 | + EPS=.0001*MIN(P0,1.-P0) |
| 77 | + E1=.0001*MIN(P0,1.-P0) |
| 78 | +C |
| 79 | +C Use bisection with appropriate routine for Chi-squared or Fisher's |
| 80 | +C exact test. |
| 81 | +C |
| 82 | + IF (UORF.EQ.1) THEN |
| 83 | +C |
| 84 | +C Set initial end points for lower end point. |
| 85 | +C |
| 86 | + Y1=0.0 |
| 87 | + Y2=P0-EPS |
| 88 | +C |
| 89 | +C Solve the equation for the lower solution. |
| 90 | +C |
| 91 | + CALL BISEC(Y1,Y2,EPS,E1,CHISQSIZE,P1L,ERRORL) |
| 92 | +C |
| 93 | +C Set initial end points for high end point. |
| 94 | +C |
| 95 | + Y1=P0+EPS |
| 96 | + Y2=1. |
| 97 | +C |
| 98 | +C Solve the equation for the upper solution. |
| 99 | +C |
| 100 | + CALL BISEC(Y1,Y2,EPS,E1,CHISQSIZE,P1H,ERRORH) |
| 101 | + ELSE |
| 102 | +C |
| 103 | +C Case of Fisher's exact test. |
| 104 | +C |
| 105 | + Y1=0.0 |
| 106 | + Y2=0.9999*P0 |
| 107 | + CALL BISEC(Y1,Y2,EPS,E1,FISHERSIZ,P1L,ERRORL) |
| 108 | + Y1=0.9999*P0+0.0001 |
| 109 | + Y2=1. |
| 110 | + CALL BISEC(Y1,Y2,EPS,E1,FISHERSIZ,P1H,ERRORH) |
| 111 | + END IF |
| 112 | +C |
| 113 | +C Calculate the relative risk and odds ratio for low end. |
| 114 | +C 21-Jan-1992 - Added calculation of Q1L to fix calculation of ODDSL. |
| 115 | +C |
| 116 | + IF (ERRORL.EQ.0) THEN |
| 117 | + RL=P1L/P0 |
| 118 | + Q1L=1.-P1L |
| 119 | + ODDSL=(P1L*Q0)/(P0*Q1L) |
| 120 | + ELSE |
| 121 | + P1L=0 |
| 122 | + RL=0 |
| 123 | + Q1L=0 |
| 124 | + ODDSL=0 |
| 125 | + END IF |
| 126 | +C |
| 127 | +C Calculate the relative risk and odds ratio for high end. |
| 128 | +C 21-Jan-1992 - Added calculation of Q1H to fix calculation of ODDSH. |
| 129 | +C |
| 130 | + IF (ERRORH.EQ.0) THEN |
| 131 | + RH=P1H/P0 |
| 132 | + Q1H=1.-P1H |
| 133 | + ODDSH=(P1H*Q0)/(P0*Q1H) |
| 134 | + ELSE |
| 135 | + P1H=0 |
| 136 | + RH=0 |
| 137 | + Q1H=0 |
| 138 | + ODDSH=0 |
| 139 | + END IF |
| 140 | +C |
| 141 | +C Done. |
| 142 | +C |
| 143 | + RETURN |
| 144 | + END |
0 commit comments