$c********************************************************** THIS IS A GLIM4 MACRO Localised melanoma diagnosed in Finland 1975-1994. This command file reproduces the sample analyses shown in Chapter 11 of the software manual for the relative survival analysis program, and then uses the Dyba and Hakulinen macro to estimate model-based CRSRs with 95 percent CIs (which are shown in Table 11.2 of the manual). The data file is included in the command file. To reproduce the results in Table 11.2, simply start GLIM4 and issue the directive "input 'tadek.glm'", except with dollar symbols in place of the ". Note that the original Dyba and Hakulinen macro was written for GLIM 3.77. It has been modified slightly (an additional NUMBER directive) so that it will work with this example. There is no guarantee that the macro will run with other examples, although Tadek Dyba plans to update the macro to GLIM4 some time in the future. Paul Dickman (paul.dickman@mep.ki.se) November 1998 $c********************************************************** $ $c********************************************************** $c Read in the macro $c (downloaded from http://www.nag.co.uk/stats/GDGE/issue23/dyba_mac.txt) $c (documented in GLIM Newsletter 23) $c (modified slightly to run this example in GLIM4) $c********************************************************** $ $subfile sub1 $mac hvb1 $page$$e $mac hvbi $cal %a=(%pag==0)$switch %a hvb1! $pri 'The macro calculates cumulative relative survival rates with standard error for a particular stratum, chosen by user,based on the model for survival data ( Hakulinen, T.Tenkanen,L.(1987):Regression analysis of relative survival rates.Appl.Stat. 36:309-317 ) with binomial assumption for number of deaths. The macro accepts the model with no more than two numerical variables, no more than two interactions between a categorical follow-up variable and numerical variables,no more than two interactions between a categorical follow-up variable and other categorical variables,no more than two interactions between other categorical variables than follow-up and numerical variables,and any number of other categorical variables and interactions between them. Model fitting : ---------------- It is assumed that in the fitted model the categorical follow-up variable comes first.The model includes aliased parameters (command "alias" before fitting is required),but no constant term( "fit .... - 1" ). Using macros: --------------- **First use macro vbi1, which creates vectors NFU,IFC,IFN,ICN,VNU,VCA and puts the values of these vectors to 0. **Then put the number of follow-up intervals to the vector NFU. **If interactions between follow-up and categorical variables exist in the model: "cal IFC(1)=subscript (as printed by "d e") of the model parameter FU(1).C(level of the categorical variable,which defines ^ ^ the stratum ,chosen by user) | |_____categorical variable |__________follow-up variable "cal IFC(2)=number of levels of the categorical variable,which is in interaction with follow-up. "cal IFC(3)= | Like above in IFC(1),IFC(2), respectively, but for interaction "cal IFC(4)= | for the second categorical variable If there are no such interactions ,skip the above commands. **If interactions between follow-up and numerical variables exist in the model: "cal IFN(1)=subscript (as printed by "d e") of the model parameter FU(1).N ^ ^ | |_____numerical variable |_____follow-up variable "cal IFN(2)=value of the numerical variable,which defines the stratum, chosen by user. "cal IFN(3)= | Like above in IFN(1),IFN(2), respectively, but for interaction "cal IFN(4)= | for the second numerical variable If there are no such interactions ,skip the above commands. **If interactions between other categorical variables than follow-up and numerical variables exist in the model: "cal ICN(1)=subscript (as printed by "d e") of the model parameter of the interaction term "cal ICN(2)=value of the numerical variable,which defines the stratum, chosen by user. "cal ICN(3)= | Like above in ICN(1),ICN(2), respectively, but for the second "cal ICN(4)= | interaction If there are no such interactions ,skip the above commands. **If numerical variables exist in the model: "cal VNU(1)=subscript (as printed by "d e") of the model parameter of the first numerical variable "cal VNU(2)=value of the numerical variable,which defines the stratum, chosen by user. "cal VNU(3)= | Like above in VNU(1),VNU(2), respectively, but "cal VNU(4)= | for the second numerical variable If there are no numerical variables, skip the above commands. **If categorical variables other than follow-up and interactions between them exist in the model: "cal VCA(1)= |subscripts (as printed by "d e") of the model parameters "cal VCA(2)= |of categorical variables and interactions between categorical "cal VCA(3)= |variables, which define the stratum, chosen by user, . |in any order. . | . | If the number of these parameters is greater than 20, delete vector VCA ("del VCA")and by command "ass VCA=.,.,. " create a new vector as long as needed. If there is no such situation ,skip the above commands. **For checking contents of the created vectors you can use the macro con. **In the end use macro vbin which uses the created vectors and calculates CRSR with s.e.(CRSR) for the desired stratum.'! $switch %a hvb1$$e ! ! $sub sub2 $MAC VBI1 $ASS nfu=0:ifc=0,0,0,0:ifn=0,0,0,0:icn=0,0,0,0:vnu=0,0,0,0 :vca=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0! $$END_VBI1 !****************************************************************************** $MAC VDE1 ! helping macro for macro VDER $CAL %b=ifc(1)+(%f-1)*ifc(2):%c=ifc(3)+(%f-1)*ifc(4)! $CAL %d=(ifn(1)+%f-1)*(ifn(1)/=0):%e=(ifn(3)+%f-1)*(ifn(3)/=0)! $CAL %g=%EXP(%a+%PE(%f)+%PE(%b)+%PE(%c)+%PE(%d)+%PE(%e)) : DER(%c)=DER(%b)=DER(%f)=%g: DER(%d)=%g*ifn(2): DER(%e)=%g*ifn(4) : %h=%h+%g: %f=%f+1: %z = ( %f <= %K )! $$end_VDE1 ! $MAC VDER ! Macro calculates Z-vector of derivatives ! The following line has been changed from the original ! version (instead: ASS CRSR=1) so that it runs with this ! specific example under GLIM4. There is no gaurantee that ! it will work with other examples under GLIM4. $NUMBER CRSR$CAL CRSR=1 $VAR %pl DER$CAL DER=%h=0:%f=%z=1! $CAL %a=%PE(icn(1))*icn(2)+%PE(icn(3))*icn(4)+ %PE(vnu(1))*vnu(2)+%PE(vnu(3))*vnu(4)+%cu(%PE(vca))! $WHILE %z VDE1! $CAL CRSR=%EXP(-%h): DER(vca)=%h: DER(vnu(1))=%h*vnu(2) : DER(vnu(3))=%h*vnu(4): DER(icn(1))=%h*icn(2) : DER(icn(3))=%h*icn(4): DER=-DER*CRSR! $PRI 'Cum. Rel. Sur. Rate = 'crsr! $$END_VDER !****************************************************************************** $MAC MDE1 ! helping macro for macro MDER $CAL %i= %i+1$ASS IDI=IDI,%i:A=A,1! $CAL A=DER(%i)*DER(IDI)$ASS DERI=DERI,A! $CAL %m = ( %i+1 <= %PL )$$ $END_MDE1 ! $MAC MDER ! Macro calculates the lower triangul of the matrix (ZZ^ ) $CAL %m=1$VAR 1 DERI IDI ! ^ - sign for transpose $CAL %i=1: %m=1: IDI=1 :DERI=DER(1)**2$ASS A=1! $WHILE %m MDE1$DEL A IDI DER $$ $END_MDER !****************************************************************************** $MAC MWE1 ! helping macro for macro MWEI $ASS X=X,2: WC=WC,X: WC=WC,1! $CAL %j=%j+1:%i=%i+%j+1! $CAL %m=( %i <= %PL*(%PL+1)/2)$$ $END_MWE1 ! $MAC MWEI ! Macro calculates weights(1 or 2) for matrix V $CAL %m=1! $VAR 1 x$CAL %i=3:%j=2:X=2$ASS WC=1,2,1 $WHI %m MWE1$DEL X! $$END_MWEI !****************************************************************************** $MAC CVAR ! Macro calculates tr((ZZ^ )V^ ), where ^ - sign for transpose; $CAL %v=%CU(DERI*WC*%VC):%v=%SQR(%v)! for given follow-up interval $PRI 'se(CRSR) = ' %v! for given stratum $CA %l=crsr-1.96*%v:%r=crsr+1.96*%v! $PRI ' 95 % C.I. = ' %l' <='crsr' <='%r :'-------------------------------------------------------------'$$ $END_CVAR !****************************************************************************** $MAC VBI2 ! helping macro for macro VBIN $EXTR %PE %VC$PRI :::'AFTER FOLLOW-UP =' %K! $USE VDER$USE MDER$USE MWEI$USE CVAR! $CAL %K=%K+1:%N=( %K<=NFU )$DEL DERI! $$END_VBI2 ! $MAC VBIN!********************************************************************* $CAL %K=%N=1$WHILE %N VBI2$$!** M A I N MACRO********************************** $END_VBIN!********************************************************************* ! $mac con $pri 'nfu = 'nfu:'ifc = 'ifc:'ifn = 'ifn :'icn = 'icn:'vnu = 'vnu:'vca= 'vca$$end_con ! $c********************************************************** $c Now read in the data and fit the model $c********************************************************** $ $echo on$ $tran i o f h $ $warn $ $unit 80 ! number of observations $data fu nd ld ps SEX AGE v3 DGNyear nAGE $ $factor fu 5 SEX 2 AGE 4 v3 1 DGNyear 2 $ $c $echo off$ $read 1 3 270.5 0.99719 1 2 1 1 40.00 2 13 267.0 0.99703 1 2 1 1 40.00 3 18 254.0 0.99681 1 2 1 1 40.00 4 9 236.0 0.99657 1 2 1 1 40.00 5 9 227.0 0.99630 1 2 1 1 40.00 1 5 342.0 0.99733 1 2 1 2 40.00 2 10 324.5 0.99714 1 2 1 2 40.00 3 6 287.0 0.99697 1 2 1 2 40.00 4 13 254.0 0.99684 1 2 1 2 40.00 5 3 216.0 0.99669 1 2 1 2 40.00 1 5 291.0 0.98779 1 3 1 1 52.00 2 23 286.0 0.98701 1 3 1 1 52.00 3 21 263.0 0.98615 1 3 1 1 52.00 4 12 242.0 0.98523 1 3 1 1 52.00 5 14 230.0 0.98430 1 3 1 1 52.00 1 7 503.0 0.99090 1 3 1 2 52.00 2 19 471.5 0.99028 1 3 1 2 52.00 3 23 406.0 0.98944 1 3 1 2 52.00 4 11 337.0 0.98872 1 3 1 2 52.00 5 13 283.0 0.98783 1 3 1 2 52.00 1 17 275.0 0.96019 1 1 1 1 67.00 2 34 258.0 0.95771 1 1 1 1 67.00 3 32 224.0 0.95489 1 1 1 1 67.00 4 15 192.0 0.95241 1 1 1 1 67.00 5 13 177.0 0.94929 1 1 1 1 67.00 1 10 449.0 0.96772 1 1 1 2 67.00 2 34 415.0 0.96542 1 1 1 2 67.00 3 22 332.5 0.96191 1 1 1 2 67.00 4 27 267.0 0.95884 1 1 1 2 67.00 5 20 203.5 0.95541 1 1 1 2 67.00 1 11 74.0 0.87852 1 4 1 1 80.00 2 10 63.0 0.87421 1 4 1 1 80.00 3 16 53.0 0.87480 1 4 1 1 80.00 4 6 37.0 0.87256 1 4 1 1 80.00 5 7 31.0 0.86427 1 4 1 1 80.00 1 24 200.0 0.88740 1 4 1 2 80.00 2 37 165.0 0.88223 1 4 1 2 80.00 3 20 110.5 0.87558 1 4 1 2 80.00 4 11 76.5 0.86933 1 4 1 2 80.00 5 9 54.0 0.86593 1 4 1 2 80.00 1 1 381.0 0.99912 2 2 1 1 40.00 2 6 379.0 0.99907 2 2 1 1 40.00 3 8 372.0 0.99900 2 2 1 1 40.00 4 3 364.0 0.99891 2 2 1 1 40.00 5 10 361.0 0.99884 2 2 1 1 40.00 1 0 469.0 0.99912 2 2 1 2 40.00 2 6 450.0 0.99905 2 2 1 2 40.00 3 6 401.5 0.99897 2 2 1 2 40.00 4 5 354.0 0.99887 2 2 1 2 40.00 5 6 305.5 0.99877 2 2 1 2 40.00 1 7 343.0 0.99603 2 3 1 1 52.00 2 13 336.0 0.99572 2 3 1 1 52.00 3 16 323.0 0.99537 2 3 1 1 52.00 4 13 307.0 0.99498 2 3 1 1 52.00 5 5 294.0 0.99455 2 3 1 1 52.00 1 2 438.0 0.99664 2 3 1 2 52.00 2 11 414.5 0.99637 2 3 1 2 52.00 3 6 360.0 0.99607 2 3 1 2 52.00 4 8 307.5 0.99576 2 3 1 2 52.00 5 5 256.0 0.99551 2 3 1 2 52.00 1 8 353.0 0.98141 2 1 1 1 67.00 2 24 345.0 0.97982 2 1 1 1 67.00 3 29 321.0 0.97772 2 1 1 1 67.00 4 21 292.0 0.97568 2 1 1 1 67.00 5 9 271.0 0.97354 2 1 1 1 67.00 1 12 459.0 0.98370 2 1 1 2 67.00 2 22 425.0 0.98208 2 1 1 2 67.00 3 18 357.5 0.98018 2 1 1 2 67.00 4 13 295.5 0.97809 2 1 1 2 67.00 5 12 246.5 0.97608 2 1 1 2 67.00 1 11 157.0 0.92082 2 4 1 1 80.00 2 26 146.0 0.91458 2 4 1 1 80.00 3 16 120.0 0.90651 2 4 1 1 80.00 4 13 104.0 0.90065 2 4 1 1 80.00 5 15 91.0 0.89525 2 4 1 1 80.00 1 27 312.5 0.91563 2 4 1 2 80.00 2 39 270.0 0.90888 2 4 1 2 80.00 3 30 205.0 0.90208 2 4 1 2 80.00 4 31 154.0 0.89941 2 4 1 2 80.00 5 15 103.0 0.89554 2 4 1 2 80.00 $ $macro m1 $calc exlp = -%exp(%lp) $calc %fv = %exp(exlp)*ld*ps $calc %dr = 1/(%fv*exlp) $endmac $ $macro m2 $calc %lp = 0.8$ $endmac $ $macro m3 $calc %va = %fv*(1-%fv/ld) $calc %di = 2*(%yv*%log(%yv/%fv) + (ld - %yv)*%log((1 - %yv/ld)/(1 - %fv/ld))) $endmac $ $calc ns = ld - nd $yvar ns $ $err o m3 $ $link o m1 $ $init m2 $ $ $mac rira $var %pl vari expe loli upli ein cuni ccun $extr %pe %vc $calc expe = %exp(%pe) $var %ml hilf $calc hilf = %vc $calc ein = 1 $calc cuni = %cu(ein) $calc ccun = %cu(cuni) $calc vari = hilf(ccun) $calc loli = expe*%exp(-1.96*%sqrt(vari)) $calc upli = expe*%exp(1.96*%sqrt(vari)) $print 'risk ratios with 95% ci' $look expe loli upli $del vari expe loli upli ein cuni ccun hilf $endmac $echo on$ $c************************************************************* Fit the model using the default settings. This is the analysis reported in Chapter 11 of the manual. The covariance matrix is scaled by the scale parameter, but the likelihood is not. $c************************************************************* $fit fu+age+sex+dgnyear$ $dis e$ $ $c************************************************************* $c Estimates of the cum. RSR are required for males (parameter 10), $c aged 45-59 (parameter 8), diagnosed during 1975-84 (parameter 12). $c************************************************************* $ $alias$ $fit -1+fu+age+sex+dgnyear$ $dis e$ $use vbi1$ $cal vca(1)=8:vca(2)=10:vca(3)=12:nfu=5$ $use con$ $use vbin$ $ $return$ $finish$