[3f72c3]: / predict_lca_risk.do

Download this file

42 lines (33 with data), 1.1 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
clear all
clear mata
version 12
adopath ++ ./ado
*************************************************************
// configuration
local nyears 2 // 5-year predicted probability, change to any reasonable horizon
local input_file "input.csv"
local output_file "output.csv"
*************************************************************
insheet using `input_file', comma names
// get list of variable names
qui ds
local vars `r(varlist)'
// generate a unique id for sorting the data as they were entered
gen sid=_n
// generate splines for cigs/day
rcsgen ncig if smoke_stat==1, knots(4 15 30) gen(smkfmr_ncig_sp2_)
rcsgen ncig if smoke_stat==2, knots(4 15 30) gen(smkcur_ncig_sp2_)
// new variables to match those from the models
gen prebl_cancer=previous_cancer
gen atnd_age=age
gen sex=male
gen smkcur_stop1day_easy=stop1day_easy
gen outcome=1
gen exit=age+1
stset exit, enter(age) fail(outcome)
make_predictions, nyears(`nyears') time0(age)
sort sid
keep `vars' cif_lung
outsheet using `output_file', c replace
exit
*************************************************************