generated from opensafely/research-template
/
200_itsa_models.do
86 lines (60 loc) · 3.44 KB
/
200_itsa_models.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
version 16
/*==============================================================================
DO FILE NAME: ITSA models
PROJECT: Gout OpenSAFELY project
DATE: 01/12/2022
AUTHOR: M Russell / J Galloway
DESCRIPTION OF FILE: ITSA models
DATASETS USED: main data file
DATASETS CREATED: tables
OTHER OUTPUT: logfiles, printed to folder $Logdir
USER-INSTALLED ADO:
(place .ado file(s) in analysis folder)
==============================================================================*/
**Set filepaths
*global projectdir "C:\Users\k1754142\OneDrive\PhD Project\OpenSAFELY Gout\OpenSAFELY gout"
*global projectdir "C:\Users\Mark\OneDrive\PhD Project\OpenSAFELY Gout\OpenSAFELY gout"
global projectdir `c(pwd)'
capture mkdir "$projectdir/output/data"
capture mkdir "$projectdir/output/tables"
capture mkdir "$projectdir/output/figures"
global logdir "$projectdir/logs"
**Open a log file
cap log close
log using "$logdir/itsa_models.log", replace
**Set Ado file path
adopath + "$projectdir/analysis/extra_ados"
**Use cleaned data from previous step
use "$projectdir/output/data/file_gout_all.dta", clear
set scheme plotplainblind
*Restrict all analyses to patients with at least 6m follow-up and registration after diagnosis================*/
keep if has_6m_post_diag==1
*ITSA models for ULT prescription ===========================================================================*/
**Time from diagnosis to prescription of ULT
preserve
tab ult_6m
tab mo_year_diagn ult_6m, row
collapse (mean) mean_ult_delay=ult_6m, by(mo_year_diagn)
tsset mo_year_diagn
**Newey Standard Errors with 5 lags
itsa mean_ult_delay if inrange(mo_year_diagn, tm(2015m1), tm(2022m6)), single trperiod(2020m4) lag(5) replace figure(title("", size(small)) subtitle("", size(medsmall)) ytitle("Proportion prescribed ULT within 6 months", size(medsmall) margin(small)) xlabel(, nogrid) yscale(range(0(0.1)0.5)) ylabel(0 "0" 0.1 "0.1" 0.2 "0.2" 0.3 "0.3" 0.4 "0.4" 0.5 "0.5", format(%03.1f) nogrid) xtitle("Date of diagnosis", size(medsmall) margin(medsmall)) note("", size(v.small)) legend(off)) posttrend
graph export "$projectdir/output/figures/ITSA_ult_newey.svg", as(svg) replace
actest, lag(18)
restore
*Restrict all analyses to patients prescribed ULT within 6m who had at least 6m follow-up after ULT================*/
use "$projectdir/output/data/file_gout_all.dta", clear
keep if has_6m_follow_up_ult==1 & ult_6m==1
//Could also look at target attainment overall; i.e. irrespective of ULT
*ITSA models for urate attainment ===========================================================================*/
**Time from diagnosis to prescription of ULT
preserve
tab urate_below360_ult_6m
tab mo_year_diagn urate_below360_ult_6m, row
collapse (mean) mean_360_delay=urate_below360_ult_6m, by(mo_year_diagn)
tsset mo_year_diagn
**Newey Standard Errors with 5 lags
itsa mean_360_delay if inrange(mo_year_diagn, tm(2015m1), tm(2022m6)), single trperiod(2020m4) lag(5) replace figure(title("", size(small)) subtitle("", size(medsmall)) ytitle("Proportion attaining urate <360 within 6 months of ULT", size(medsmall) margin(small)) xlabel(, nogrid) yscale(range(0(0.1)0.5)) ylabel(0 "0" 0.1 "0.1" 0.2 "0.2" 0.3 "0.3" 0.4 "0.4" 0.5 "0.5", format(%03.1f) nogrid) xtitle("Date of diagnosis", size(medsmall) margin(medsmall)) note("", size(v.small)) legend(off)) posttrend
graph export "$projectdir/output/figures/ITSA_360_newey.svg", as(svg) replace
actest, lag(18)
restore
log close