Dear All,
I want to estimate the effect of treatment (COVID) on a survival outcome using matching. I am trying to match on the 8 pre-treatment period observables, but am not sure how to incorporate which pairs are matched in the final stcrreg regression:
But shouldn't the matched 'pair' be somehow incorporated into the final regression or does including the _weight in the sttset already do that?
Here is a dataex:
I would be very grateful for any help you may be able to offer.
Many thanks in advance,
Sumedha
I want to estimate the effect of treatment (COVID) on a survival outcome using matching. I am trying to match on the 8 pre-treatment period observables, but am not sure how to incorporate which pairs are matched in the final stcrreg regression:
Code:
. preserve
. bysort grpatid: gen counter=_n /*create period counter*/
. reshape wide age75plus tavg lnprcp chf cad cancer copd dm stroke htn oarth liver renal depress cumchf_f cumcad_f cumcancer_f cumcopd_f cumdm_f cumstrok
> e_f cumhtn_f cumoarth_f cumliver_f cumrenal_f cumdepress_f, i(grpatid) j(counter)
(j = 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)
Data Long -> Wide
-----------------------------------------------------------------------------
Number of observations 50,166 -> 1,703
Number of variables 45 -> 794
j variable (31 values) counter -> (dropped)
xij variables:
age75plus -> age75plus1 age75plus2 ... age75plus31
tavg -> tavg1 tavg2 ... tavg31
lnprcp -> lnprcp1 lnprcp2 ... lnprcp31
chf -> chf1 chf2 ... chf31
cad -> cad1 cad2 ... cad31
cancer -> cancer1 cancer2 ... cancer31
copd -> copd1 copd2 ... copd31
dm -> dm1 dm2 ... dm31
stroke -> stroke1 stroke2 ... stroke31
htn -> htn1 htn2 ... htn31
oarth -> oarth1 oarth2 ... oarth31
liver -> liver1 liver2 ... liver31
renal -> renal1 renal2 ... renal31
depress -> depress1 depress2 ... depress31
cumchf_f -> cumchf_f1 cumchf_f2 ... cumchf_f31
cumcad_f -> cumcad_f1 cumcad_f2 ... cumcad_f31
cumcancer_f -> cumcancer_f1 cumcancer_f2 ... cumcancer_f31
cumcopd_f -> cumcopd_f1 cumcopd_f2 ... cumcopd_f31
cumdm_f -> cumdm_f1 cumdm_f2 ... cumdm_f31
cumstroke_f -> cumstroke_f1 cumstroke_f2 ... cumstroke_f31
cumhtn_f -> cumhtn_f1 cumhtn_f2 ... cumhtn_f31
cumoarth_f -> cumoarth_f1 cumoarth_f2 ... cumoarth_f31
cumliver_f -> cumliver_f1 cumliver_f2 ... cumliver_f31
cumrenal_f -> cumrenal_f1 cumrenal_f2 ... cumrenal_f31
cumdepress_f -> cumdepress_f1 cumdepress_f2 ... cumdepress_f31
-----------------------------------------------------------------------------
.
. psmatch2 treat state_d Female age75plus1 age75plus2 age75plus3 age75plus4 age75plus5 age75plus16 age75plus7 age75plus8 Asian Black Hispanic lnPopDensit
> y tavg1 tavg2 tavg3 tavg4 tavg5 tavg6 tavg7 tavg8 lnprcp1 lnprcp2 lnprcp3 lnprcp4 lnprcp5 lnprcp6 lnprcp7 lnprcp8 chf_b cad_b cancer_b copd_b dm_b stro
> ke_b htn_b oarth_b liver_b renal_b depress_b , ties
note: age75plus2 omitted because of collinearity.
note: age75plus3 omitted because of collinearity.
note: age75plus4 omitted because of collinearity.
note: age75plus5 omitted because of collinearity.
note: age75plus7 omitted because of collinearity.
note: age75plus8 omitted because of collinearity.
Probit regression Number of obs = 1,627
LR chi2(35) = 67.01
Prob > chi2 = 0.0009
Log likelihood = -517.68107 Pseudo R2 = 0.0608
------------------------------------------------------------------------------
treat | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
state_d | .0101961 .0053687 1.90 0.058 -.0003263 .0207185
Female | -.1764547 .0888231 -1.99 0.047 -.3505449 -.0023646
age75plus1 | .0276325 .2025255 0.14 0.891 -.3693103 .4245753
age75plus2 | 0 (omitted)
age75plus3 | 0 (omitted)
age75plus4 | 0 (omitted)
age75plus5 | 0 (omitted)
age75plus16 | .061685 .1995193 0.31 0.757 -.3293656 .4527357
age75plus7 | 0 (omitted)
age75plus8 | 0 (omitted)
Asian | .1135679 .263324 0.43 0.666 -.4025377 .6296734
Black | -.1448756 .1527226 -0.95 0.343 -.4442065 .1544552
Hispanic | .1313628 .1440939 0.91 0.362 -.1510559 .4137816
lnPopDensity | .176917 .1240405 1.43 0.154 -.0661978 .4200319
tavg1 | .023828 .2270113 0.10 0.916 -.421106 .468762
tavg2 | .0198481 .2761293 0.07 0.943 -.5213552 .5610515
tavg3 | .0951089 .15344 0.62 0.535 -.205628 .3958457
tavg4 | -.0598312 .0926228 -0.65 0.518 -.2413686 .1217061
tavg5 | -.0177726 .2445209 -0.07 0.942 -.4970247 .4614794
tavg6 | .1510144 .2468117 0.61 0.541 -.3327277 .6347564
tavg7 | -.0741244 .206211 -0.36 0.719 -.4782904 .3300417
tavg8 | -.0959662 .112928 -0.85 0.395 -.317301 .1253686
lnprcp1 | -.054779 .2997335 -0.18 0.855 -.6422459 .5326878
lnprcp2 | .0383508 .3075831 0.12 0.901 -.564501 .6412026
lnprcp3 | -.1618274 .141706 -1.14 0.253 -.4395661 .1159114
lnprcp4 | -.0255357 .0840448 -0.30 0.761 -.1902604 .139189
lnprcp5 | -.1859812 .2462032 -0.76 0.450 -.6685305 .2965681
lnprcp6 | .3399121 .266266 1.28 0.202 -.1819597 .8617839
lnprcp7 | -.330242 .3905652 -0.85 0.398 -1.095736 .4352518
lnprcp8 | .1491762 .2697388 0.55 0.580 -.3795021 .6778544
chf_b | .3893635 .2031189 1.92 0.055 -.0087422 .7874693
cad_b | -.500356 .2751061 -1.82 0.069 -1.039554 .038842
cancer_b | .0518006 .135363 0.38 0.702 -.2135061 .3171072
copd_b | .1001201 .1491387 0.67 0.502 -.1921863 .3924266
dm_b | .0603563 .1102821 0.55 0.584 -.1557926 .2765051
stroke_b | -.5330403 .5471012 -0.97 0.330 -1.605339 .5392583
htn_b | .2421702 .0982421 2.47 0.014 .0496193 .4347212
oarth_b | .0156505 .1823614 0.09 0.932 -.3417713 .3730723
liver_b | .0174328 .2858999 0.06 0.951 -.5429208 .5777864
renal_b | .0909087 .133533 0.68 0.496 -.1708112 .3526287
depress_b | .1411918 .1638635 0.86 0.389 -.1799747 .4623583
_cons | -3.852092 2.356527 -1.63 0.102 -8.4708 .7666153
------------------------------------------------------------------------------
.
. keep grpatid _pscore- _pdif
. *generate pair from output
. gen pair=.
(1,703 missing values generated)
. replace pair =_id if _treated==0
(1,454 real changes made)
. replace pair= _n1 if _treated==1
(173 real changes made)
. replace pair=. if _weight==.
(1,160 real changes made, 1,160 to missing)
. save "psmatch_point05pct_treated.dta", replace
. restore
.
. merge m:1 grpatid using "psmatch_point05pct_treated.dta", keep(3) nogen
Result Number of obs
-----------------------------------------
Not matched 0
Matched 50,166
-----------------------------------------
. drop if _weight==.
(36,116 observations deleted)
.
. stset stop [pw=_weight], id(grpatid) enter(start) failure(d2=1) time0(start)
Survival-time data settings
ID variable: grpatid
Failure event: d2==1
Observed time interval: (start, stop]
Enter on or after: time start
Exit on or before: failure
Weight: [pweight=_weight]
--------------------------------------------------------------------------
14,050 total observations
0 exclusions
--------------------------------------------------------------------------
14,050 observations remaining, representing
467 subjects
27 failures in single-failure-per-subject data
14,050 total analysis time at risk and under observation
At risk from t = 0
Earliest observed entry t = 0
Last observed exit t = 31
.
. eststo: stcrreg Female age75plus Asian Black Hispanic chf_b cad_b cancer_b copd_b dm_b stroke_b htn_b oarth_b liver_b renal_b depress_b COVID CumMonths
> SAH lnnursing_visits, compete(d2=2)
Failure _d: d2==1
Analysis time _t: stop
Enter on or after: time start
ID variable: grpatid
Weight: [pweight=_weight]
Iteration 0: Log pseudolikelihood = -192.48387
Iteration 1: Log pseudolikelihood = -192.05237
Iteration 2: Log pseudolikelihood = -192.04966
Iteration 3: Log pseudolikelihood = -192.04964
Iteration 4: Log pseudolikelihood = -192.04963
Competing-risks regression No. of obs = 13,635
No. of subjects = 467
Failure event: d2 == 1 No. failed = 26
Competing event: d2 == 2 No. competing = 28
No. censored = 413
Wald chi2(19) = 2387.66
Log pseudolikelihood = -192.04963 Prob > chi2 = 0.0000
(Std. err. adjusted for 467 clusters in grpatid)
----------------------------------------------------------------------------------
| Robust
_t | SHR std. err. z P>|z| [95% conf. interval]
-----------------+----------------------------------------------------------------
Female | 3.064866 1.68689 2.03 0.042 1.042111 9.013829
age75plus | 1.207451 .5368349 0.42 0.672 .5051539 2.886126
Asian | 2.66e-07 1.66e-07 -24.22 0.000 7.82e-08 9.07e-07
Black | .4487784 .3278344 -1.10 0.273 .1072077 1.878616
Hispanic | .3482283 .3669299 -1.00 0.317 .0441518 2.746499
chf_b | 1.310732 .9467288 0.37 0.708 .3181995 5.399187
cad_b | 7.134107 5.745512 2.44 0.015 1.471694 34.58293
cancer_b | .7528565 .8304606 -0.26 0.797 .0866501 6.541166
copd_b | 1.667023 1.02421 0.83 0.406 .4999975 5.557959
dm_b | .6457047 .3659011 -0.77 0.440 .2126592 1.960576
stroke_b | 19.18389 18.76927 3.02 0.003 2.81924 130.5393
htn_b | .9629506 .5475104 -0.07 0.947 .3159595 2.934787
oarth_b | 1.957083 1.460144 0.90 0.368 .4534641 8.446474
liver_b | 2.42e-07 3.37e-07 -10.94 0.000 1.58e-08 3.71e-06
renal_b | 3.848813 2.932669 1.77 0.077 .8644488 17.1362
depress_b | 1.835248 1.099269 1.01 0.311 .5673433 5.936681
COVID | .5705513 .3140267 -1.02 0.308 .1939994 1.677988
CumMonthsSAH | .6244314 .238847 -1.23 0.218 .2950512 1.321515
lnnursing_visits | 1.146258 .2422881 0.65 0.518 .7574626 1.734616
----------------------------------------------------------------------------------
(est93 stored)
But shouldn't the matched 'pair' be somehow incorporated into the final regression or does including the _weight in the sttset already do that?
Here is a dataex:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(treat Female age75plus) byte(Asian Black Hispanic) float(COVID CumMonthsSAH lnnursing_visits d2) byte(_st _d _t _t0) int(_id _n1) float _nn double _pdif float pair 0 1 0 0 0 0 0 .8333333 11.508034 0 1 0 22 21 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.78502 0 1 0 29 28 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.3792 0 1 0 13 12 430 . 0 . 430 0 1 0 0 0 0 0 0 11.699944 0 1 0 3 2 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.43734 0 1 0 16 15 430 . 0 . 430 0 1 0 0 0 0 0 0 11.549827 0 1 0 9 8 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.56043 0 1 0 19 18 430 . 0 . 430 0 1 0 0 0 0 0 0 11.59666 0 1 0 1 0 430 . 0 . 430 0 1 0 0 0 0 0 0 11.26563 0 1 0 10 9 430 . 0 . 430 0 1 0 0 0 0 0 0 11.777856 0 1 0 8 7 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.320626 0 1 0 11 10 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.755024 0 1 0 27 26 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.787697 0 1 0 26 25 430 . 0 . 430 0 1 0 0 0 0 0 0 11.74062 0 1 0 6 5 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.477817 0 1 0 20 19 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.754592 0 1 0 25 24 430 . 0 . 430 0 1 0 0 0 0 0 0 11.631082 0 1 0 5 4 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 . 0 1 0 31 30 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.828933 0 1 0 30 29 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.482714 0 1 0 21 20 430 . 0 . 430 0 1 0 0 0 0 0 0 11.66851 0 1 0 2 1 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.394693 0 1 0 14 13 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.543426 0 1 0 18 17 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.35496 0 1 0 17 16 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.812682 0 1 0 28 27 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.3682 0 1 0 12 11 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.753028 0 1 0 23 22 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.737787 0 1 0 24 23 430 . 0 . 430 0 1 0 0 0 0 0 .8333333 11.39811 0 1 0 15 14 430 . 0 . 430 0 1 0 0 0 0 0 0 11.873713 0 1 0 7 6 430 . 0 . 430 0 1 0 0 0 0 0 0 11.65453 0 1 0 4 3 430 . 0 . 430 0 1 1 0 0 0 0 1.0333333 9.643355 0 1 0 26 25 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.44715 0 1 0 22 21 169 . 0 . 169 0 1 1 0 0 0 0 0 9.813398 0 1 0 3 2 169 . 0 . 169 0 1 1 0 0 0 0 0 9.75771 0 1 0 4 3 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.273315 0 1 0 12 11 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 . 0 1 0 31 30 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.612266 0 1 0 30 29 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.709599 0 1 0 28 27 169 . 0 . 169 0 1 1 0 0 0 0 0 9.711843 0 1 0 5 4 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.235423 0 1 0 17 16 169 . 0 . 169 0 1 1 0 0 0 0 0 9.784986 0 1 0 8 7 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.30146 0 1 0 13 12 169 . 0 . 169 0 1 1 0 0 0 0 0 9.818583 0 1 0 6 5 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.685331 0 1 0 29 28 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.285727 0 1 0 16 15 169 . 0 . 169 0 1 1 0 0 0 0 0 9.939193 0 1 0 7 6 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.305832 0 1 0 19 18 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.272188 0 1 0 11 10 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.36246 0 1 0 20 19 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.164087 0 1 0 21 20 169 . 0 . 169 0 1 1 0 0 0 0 0 9.716133 0 1 0 1 0 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.641993 0 1 0 27 26 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.361945 0 1 0 18 17 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.304923 0 1 0 14 13 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.287765 0 1 0 15 14 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.621788 0 1 0 23 22 169 . 0 . 169 0 1 1 0 0 0 0 0 9.531772 0 1 0 9 8 169 . 0 . 169 0 1 1 0 0 0 0 0 9.750219 0 1 0 2 1 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.61086 0 1 0 25 24 169 . 0 . 169 0 1 1 0 0 0 0 1.0333333 9.651944 0 1 0 24 23 169 . 0 . 169 0 1 1 0 0 0 0 .033333335 9.191668 0 1 0 10 9 169 . 0 . 169 0 1 1 0 0 0 0 .8333333 11.508034 0 1 0 22 21 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.828933 0 1 0 30 29 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.755024 0 1 0 27 26 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.477817 0 1 0 20 19 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.43734 0 1 0 16 15 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.3682 0 1 0 12 11 708 . 0 . 708 0 1 1 0 0 0 0 0 11.777856 0 1 0 8 7 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.394693 0 1 0 14 13 708 . 0 . 708 0 1 1 0 0 0 0 0 11.699944 0 1 0 3 2 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 . 0 1 0 31 30 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.753028 0 1 0 23 22 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.482714 0 1 0 21 20 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.320626 0 1 0 11 10 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.737787 0 1 0 24 23 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.78502 0 1 0 29 28 708 . 0 . 708 0 1 1 0 0 0 0 0 11.549827 0 1 0 9 8 708 . 0 . 708 0 1 1 0 0 0 0 0 11.65453 0 1 0 4 3 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.543426 0 1 0 18 17 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.56043 0 1 0 19 18 708 . 0 . 708 0 1 1 0 0 0 0 0 11.26563 0 1 0 10 9 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.39811 0 1 0 15 14 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.35496 0 1 0 17 16 708 . 0 . 708 0 1 1 0 0 0 0 0 11.74062 0 1 0 6 5 708 . 0 . 708 0 1 1 0 0 0 0 0 11.873713 0 1 0 7 6 708 . 0 . 708 0 1 1 0 0 0 0 0 11.66851 0 1 0 2 1 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.754592 0 1 0 25 24 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.812682 0 1 0 28 27 708 . 0 . 708 0 1 1 0 0 0 0 0 11.59666 0 1 0 1 0 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.3792 0 1 0 13 12 708 . 0 . 708 0 1 1 0 0 0 0 0 11.631082 0 1 0 5 4 708 . 0 . 708 0 1 1 0 0 0 0 .8333333 11.787697 0 1 0 26 25 708 . 0 . 708 0 1 1 0 0 0 0 1.2 10.688416 0 1 0 29 28 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.674937 0 1 0 25 24 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.419062 0 1 0 21 20 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.713306 0 1 0 28 27 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.528222 0 1 0 15 14 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.713017 0 1 0 26 25 714 . 0 . 714 0 1 1 0 0 0 0 1.2 10.624347 0 1 0 18 17 714 . 0 . 714 end label values COVID COVID label def COVID 0 "No confirmed COVID-19", modify
Many thanks in advance,
Sumedha
