-
Notifications
You must be signed in to change notification settings - Fork 0
/
casecohort_analyses.do
73 lines (48 loc) · 2.57 KB
/
casecohort_analyses.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
*=====================================================================================================
*complete case analysis using case-cohort data
*=====================================================================================================
* load data set
import delimited caco.csv, numericcol(5) clear
stset t, failure(d) enter(entertime)
* fit the model
stcox x1 x2 z, robust nohr
*=====================================================================================================
*MI-approx full cohort: imputation and analysis performed using full cohort
*=====================================================================================================
* load data set
import delimited cohort_caco.csv, numericcol(4 5) clear
stset t, failure(d)
* Compute Nelson-Aalen estimate of the cumulative baseline hazard
sts generate H=na
*perform the imputation (10 imputations)
mi set mlong
mi register imputed x1 x2
mi register regular d t H z
mi impute chained (regress) x1 (logit) x2 = d H z, add(10)
* Fit the analysis model in each imputed data set and combine estimates across the imputed data sets using Rubin's Rules
mim: stcox x1 x2 z, nohr
*=====================================================================================================
*MI-SMC full cohort: imputation and analysis performed using full cohort
*=====================================================================================================
* load data set
import delimited cohort_caco.csv, numericcol(4 5) clear
stset t, failure(d)
*perform the imputation (10 imputations)
* Fit the analysis model in each imputed data set and combine estimates across the imputed data sets using Rubin's Rules
smcfcs stcox x1 x2 z, regress(x1) logit(x2) m(10) iterations(100)
*=====================================================================================================
*MI-approx case-cohort: imputation and analysis performed using case-cohort data
*x1 is fully observed in the case-cohort data
*=====================================================================================================
* load data set
import delimited caco.csv, numericcol(5) clear
stset t, failure(d) enter(entertime)
* Compute Nelson-Aalen estimate of the cumulative baseline hazard
sts generate H=na
*perform the imputation (10 imputations)
mi set mlong
mi register imputed x1 x2
mi register regular d t H z
mi impute chained (regress) x1 (logit) x2 = d H z, add(10)
* Fit the analysis model in each imputed data set and combine estimates across the imputed data sets using Rubin's Rules
mim: stcox x1 x2 z, robust nohr