[3f72c3]: / ado / make_predictions.ado

Download this file

67 lines (61 with data), 1.7 kB

 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
*! make_predictions.ado
*! Stata command to calculate the predicted cumulative incidence of
*! lung cancer based on given data provided and the UK Biobank lung
*! cancer risk prediction model
*!
*! dcmuller
progr define make_predictions
version 12
syntax , nyears(integer) time0(varname)
quietly estimates use ./model_binaries/m05_lung_cur.ster
quietly estimates store lung_cur
quietly estimates use ./model_binaries/m05_lung_fmr.ster
quietly estimates store lung_fmr
quietly estimates use ./model_binaries/m05_lung_nev.ster
quietly estimates store lung_nev
quietly estimates use ./model_binaries/m05_mort.ster
quietly estimates store mort
tempvar tempid
gen `tempid' = _n
tempfile nev fmr cur
qui count
local n_before = r(N)
qui count if smoke_stat==0
if `=r(N)' != 0 {
preserve
qui keep if smoke_stat==0
cr_cif lung_nev mort , ///
time(`nyears') stub(cif) time0(`time0') idvar(`tempid') intpoints(2)
rename cif_lung_nev cif_lung
qui save `nev', replace
restore
}
qui count if smoke_stat==1
if `=r(N)' != 0 {
preserve
qui keep if smoke_stat==1
cr_cif lung_fmr mort , ///
time(`nyears') stub(cif) time0(`time0') idvar(`tempid') intpoints(2)
rename cif_lung_fmr cif_lung
qui save `fmr', replace
restore
}
qui count if smoke_stat==2
if `=r(N)' != 0 {
preserve
qui keep if smoke_stat==2
cr_cif lung_cur mort , ///
time(`nyears') stub(cif) time0(`time0') idvar(`tempid') intpoints(2)
rename cif_lung_cur cif_lung
qui save `cur', replace
restore
}
qui drop in 1/`=_N'
cap append using `nev'
cap append using `fmr'
cap append using `cur'
qui count
local n_after = r(N)
assert `n_before'==`n_after'
drop cif_*_raw cif_mort
end