note echo 0 note file PRE note user sets G9 to bottom level variables which model binomial/poisson note variation note user sets G11 to any variables that are not to be linearised note user sets G10 to any bottom level variables that are to have the linearising note transformation applied to them - ie bottom level extra binomial vars note macros set G1 fixed or random part variables to be linearised note macros set G12 to fixed part variables to be linearised note macros set b5 is resp col. number, b6 bottom level + 1 name c1180 'H' C1181 'F~(H)' C1182 'H*' C1183 'P' c1184 'MASK' c1189 'Y-VAR' exist 'offs' b20 obey errchk yvar b5 NOTE GET H NOTE---------------------------------------------------------------- itnum 0 b9 switch b9 case 0: note 1st iteration obey pre_0 return case 1: note iter 1 pred g12 'H' case : note otherwise pred g12 'H' switch b12 case 1 : note residual predictions required obey predr1 ends ends switch b20 case 1 : note add offsets calc 'H' = 'H' + 'offs' ends switch b16 case 1: note mixed model calc 'H'='H'*'mask' ends NOTE GET FIRST DERRIVATIVE - F~(H) AND TRANSFORM DATA NOTE---------------------------------------------------------------- switch b10 case 0 : note 1st order binomial switch b13 case 0: note LOGIT note AL correction if 'H'>55 chan 55 99999 'H' 55 'H' calc 'F~(H)' = expo('H')*( 1+expo('H') )^(-2) leave case 1: note PROBIT calc 'F~(H)' = 0.39894228*expo(-0.5*'H'^2) leave case 2: note LOGLOG calc 'F~(H)' = expo(-expo('h'))*expo('H') leave case: say \n Use B13 = 0Logit/1Probit/2Loglog \n abort ends leave case 1,2 : note 1st order poisson calc 'F~(H)' = expo('H') leave ends gmult g1 'F~(H)' NOTE FORM "H*" = (X*)B or (X*)(B+U) NOTE---------------------------------------------------------------- pred g12 'H*' note form residual predictions X*(B+U) switch b12 case 1: OBEY PREDR2 leave ends NOTE TRANSFORM LEVEL BOTTOM LEVEL & SET DISTRIBUTIONAL CONSTRAINTS NOTE---------------------------------------------------------------- switch b10 case 0: note binomial switch b13 case 0: note LOGIT calc 'P'=alog('H') leave case 1: note PROBIT calc 'P' = 1 - npro('H') leave case 2: note LOGLOG calc 'P' = 1 - expo(-expo('H')) leave case: say \nUse B13 = 0Logit/1Probit/2Loglog abort ends calc g9 = g9 * sqrt('P'*(1-'P')/'denom') leave case 1: note poisson calc 'P' = expo('H') calc g9 = g9 * 'P'^0.5 leave case 2: note -ve binomial calc 'P' = expo('H') calc g9[1] = 'P'^0.5 calc g9[2] = 'P' leave ends NOTE wmsg "position 2" NOTE pause note level b14 extra-dist switch b14 case 0 : obey bvar leave case 1 : obey nobvar leave ends NOTE TRANSFORM RESPONSE NOTE------------------------------------------------------------ calc 'Y-VAR' = cb5 switch b20 case 1: note offsets exist calc 'H*' = 'H*' ends calc cb5 = cb5- ('P' - 'H*') NOTE ADD 2ND ORDER CORRECTIONS NOTE------------------------------------------------------------ switch b11 case 1: note remove offs nlev b1 switch b1 case 1: leave case: loop b2 2 b1 offs b2 endloop ends leave case 2: obey order2a leave ends NOTE DEAL WITH MIXED MODEL NOTE------------------------------------------------------------ switch b16 case 1 : note reset continous responses to original value, mask is set to note 1 if discrete, 0 if continuous calc cb5=cb5*'mask' calc cb5=cb5+(1-'mask')*'Y-VAR' leave ends endo