*! SIM - "A Polytomous Conditional Likelihood approach for * combining matched and unmatched case-control studies" * This file shows the code needed to implement all the estimators discussed in the paper set more off log using sim_mulugeta.log, replace * * Replace data set here *use datat, clear use I:\GebGuim\dec152009\data.dta , clear * * We admit as valid the following assumptions for the data: * 1 - There is a variable called "ctrltype" that takes the following values: "case", "match", "unmatch" * 2 - There is a strata variable that takes missing values for unmatched and a common identifier for case-controls * 3 - There is a variable that indicates whether or not the individual is a case * Preliminary Data Transformations quietly { gen subtype=0 replace subtype=1 if ctrltype=="case" replace subtype=2 if ctrltype=="match" replace subtype=3 if ctrltype=="unmatch" egen strata=group(oldsetno) /*added by MG on 07152010*/ recode strata .=0 sort subtype gen unmatch=sum(ctrltype=="unmatch") } * Subtypes are: * 1 - cases * 2 - matched controls * 3 - unmatched controls * 4 - virtual cases (n=number unmatched) * 5 - virtual matched controls (n=number cases) * 6 - virtual unmatched controls (n=number unmatched) * 7 - duplicate cases (needed for BLGIM and PLGIM) * ***************************************************************************** * Naive Approach - cases vs matched controls ***************************************************************************** * * Variables for the regression local vars "male age educ1 bmic" local vars2 "male age educ1 bmic raceg2" local vars3 "male age educ1 bmic raceg2 g572pc" * cases vs matched controls (eta1) * clogit cases g572pc `vars' if ctrltype=="case"|ctrltype=="match", or group(strata) local b_rel=_b[g572pc] local se_rel=_se[g572pc] * cases vs unmatched controls (eta2) logit cases g572pc `vars2' if ctrltype=="case"|ctrltype=="unmatch" local b_nci=_b[g572pc] local se_nci=_se[g572pc] logit, or ***************************************************************************** * Break the Match Method (BMM) ***************************************************************************** * Common eta logit cases g572pc `vars2', or foreach var in g572pc `vars2' { gen `var'_neg=-`var' } * Different eta * mlogit subtype *_neg, baseoutcome(1) rr drop *_neg ***************************************************************************** * Binary Latent Group Indicator Method (BLGIM) ***************************************************************************** ** Data Preparation ** quietly { tempfile st4 st5 st6 st7 preserve count if ctrltype=="unmatch" local nunmatch=r(N) count if ctrltype=="case" local ncases=r(N) drop _all set obs `nunmatch' foreach var in g572pc `vars' strata { gen `var'=0 } gen unmatch=_n gen cases=1 gen subtype=4 gen virtual=1 save `st4', replace drop _all set obs `ncases' foreach var in g572pc `vars' unmatch cases { gen `var'=0 } gen strata=_n gen subtype=5 gen virtual=1 save `st5', replace drop _all set obs `nunmatch' foreach var in g572pc `vars' strata cases { gen `var'=0 } gen unmatch=_n gen subtype=6 gen virtual=1 save `st6', replace restore preserve keep if cases==1 drop subtype gen subtype=7 save `st7', replace restore append using `st7' gen virtual=0 append using `st4' append using `st5' gen dummy=(subtype==5|subtype==7) egen nstrata=group(strata unmatch dummy) } * Common eta clogit cases g572pc `vars' virtual, group(nstrata) or * Different etas gen sind=(subtype==1|subtype==2) gen xint=g572pc*sind clogit cases g572pc `vars' virtual xint, group(nstrata) or lincom g572pc+xint, or **** MGS71510 I have tested it through here and it rans okay. I will check the rest later***** *********************************************************************** * Polytomous Latent Group Indicator Method (PLGIM) *********************************************************************** ** Data Preparation ** local x "g572pc" /* Replace the exposure variable here */ quietly { tempfile tmp tempvar dum2 rename nstrata oldstrata drop if subtype==7 append using `st6' gen type=subtype recode type (4=1) (5=3) (6=2) gen dum2=1 append using `st7' replace type=1 if type==. append using `st5' replace type=2 if type==. append using `st5' replace type=3 if type==. replace dum2=0 if dum2==. replace virtual=0 if virtual==. egen nstrata=group(strata unmatch dum2) sort nstrata type preserve foreach var of varlist `vars' raceg2 virtual { gen z1_`var'=0 gen z2_`var'=0 gen z3_`var'=0 bys nstrata: replace z1_`var'=-`var'[1] if type==1 bys nstrata: replace z1_`var'=-`var'[2] if type==2 bys nstrata: replace z1_`var'=-`var'[3] if type==3 bys nstrata: replace z2_`var'=-`var'[2] if type==1 bys nstrata: replace z2_`var'=-`var'[3] if type==2 bys nstrata: replace z2_`var'=-`var'[1] if type==3 bys nstrata: replace z3_`var'=-`var'[3] if type==1 bys nstrata: replace z3_`var'=-`var'[1] if type==2 bys nstrata: replace z3_`var'=-`var'[2] if type==3 } foreach var of varlist `x' { gen z1x_`var'=0 gen z2x_`var'=0 gen z3x_`var'=0 bys nstrata: replace z1x_`var'=-`var'[1] if type==1 bys nstrata: replace z1x_`var'=-`var'[2] if type==2 bys nstrata: replace z1x_`var'=-`var'[3] if type==3 bys nstrata: replace z2x_`var'=-`var'[2] if type==1 bys nstrata: replace z2x_`var'=-`var'[3] if type==2 bys nstrata: replace z2x_`var'=-`var'[1] if type==3 bys nstrata: replace z3x_`var'=-`var'[3] if type==1 bys nstrata: replace z3x_`var'=-`var'[1] if type==2 bys nstrata: replace z3x_`var'=-`var'[2] if type==3 gen z_`var'=z2x_`var'+z3x_`var' } save `tmp', replace restore drop cases gen cases=0 foreach var of varlist `vars' raceg2 virtual { gen z1_`var'=0 gen z2_`var'=0 gen z3_`var'=0 bys nstrata: replace z1_`var'=-`var'[1] if type==1 bys nstrata: replace z1_`var'=-`var'[2] if type==2 bys nstrata: replace z1_`var'=-`var'[3] if type==3 bys nstrata: replace z2_`var'=-`var'[3] if type==1 bys nstrata: replace z2_`var'=-`var'[1] if type==2 bys nstrata: replace z2_`var'=-`var'[2] if type==3 bys nstrata: replace z3_`var'=-`var'[2] if type==1 bys nstrata: replace z3_`var'=-`var'[3] if type==2 bys nstrata: replace z3_`var'=-`var'[1] if type==3 } foreach var of varlist `x' { gen z1x_`var'=0 gen z2x_`var'=0 gen z3x_`var'=0 bys nstrata: replace z1x_`var'=-`var'[1] if type==1 bys nstrata: replace z1x_`var'=-`var'[2] if type==2 bys nstrata: replace z1x_`var'=-`var'[3] if type==3 bys nstrata: replace z2x_`var'=-`var'[3] if type==1 bys nstrata: replace z2x_`var'=-`var'[1] if type==2 bys nstrata: replace z2x_`var'=-`var'[2] if type==3 bys nstrata: replace z3x_`var'=-`var'[2] if type==1 bys nstrata: replace z3x_`var'=-`var'[3] if type==2 bys nstrata: replace z3x_`var'=-`var'[1] if type==3 gen z_`var'=z2x_`var'+z3x_`var' } append using `tmp' } * Common eta clogit cases z_* z2_* z3_*, group(nstrata) or * Different eta clogit cases z2* z3*, group(nstrata) or log close exit, clear