-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrevised_analyses.R
835 lines (686 loc) · 63 KB
/
revised_analyses.R
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
#######################
### Paper revisions ###
#######################
# All additional analyses as part of the paper review process where I have not edited the main files themselves.
# Libraries
library(data.table)
library(survey)
library(broom)
library(mice)
set.seed(19610704) # So can reproduce results
### 1. Load data ###
# Load data and tidy
load(file = "S:/LLC_0009/data/Cleaned Cohorts/imputed_data.RData")
# Calculate any disruption from the imputed dataset
all_data$imp_disruption_any <- all_data$imp_disruption_appointments + all_data$imp_disruption_procedures + all_data$imp_disruption_medications # Add together
all_data$imp_disruption_any[all_data$imp_disruption_any > 1] <- 1 # Recode to binary yes/no option
# Dealing with weights
options(survey.adjust.domain.lonely = TRUE) # Let adjustments be made
options(survey.lonely.psu = "adjust") # Rather than the code fail, we set it to handle single PSUs by centering on the sample grand mean rather than strata mean - this is quite conservative
# Create measure for age-squared
all_data$imp_age2 <- all_data$imp_age^2
# Define survey design
wgt <- svydesign(id = ~LLC_0009_stud_id, weights = ~weight, strata = ~strata, fpc = ~fpc, nest = TRUE, survey.lonely.psu = "adjust", data = all_data)
### 2. Descriptive table by disruption ###
# Unweighted tables
# Easier to add together the totals manually rather than me code them yes I am being lazy, but stressed getting these revisions done
# Sex
table1 <- data.frame(table(all_data$imp_sex, all_data$imp_disruption_any)) # Save frequency table
table1$measure <- "Sex" # Note measure
# Ethnicity
hold <- data.frame(table(all_data$imp_not_white, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Ethnicity" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Tenure
hold <- data.frame(table(all_data$imp_own_home, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Tenure" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Self-rated health
hold <- data.frame(table(all_data$imp_general_health, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Self-rated health" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# IMD
hold <- data.frame(table(all_data$imp_imd2019_income_q5, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "IMD" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Age
table1 <- rbind(table1, data.frame(Var1 = "age", Var2 = 0, Freq = mean(all_data$imp_age[all_data$imp_disruption_any == 0]), measure = "age")) # No disruption
table1 <- rbind(table1, data.frame(Var1 = "age", Var2 = 1, Freq = mean(all_data$imp_age[all_data$imp_disruption_any == 1]), measure = "age")) # Disruption
table1 <- rbind(table1, data.frame(Var1 = "age", Var2 = 1, Freq = mean(all_data$imp_age), measure = "age")) # Total
# Charlson index
table1 <- rbind(table1, data.frame(Var1 = "Charlson", Var2 = 0, Freq = mean(all_data$imp_quan_cci[all_data$imp_disruption_any == 0]), measure = "age")) # No disruption
table1 <- rbind(table1, data.frame(Var1 = "Charlson", Var2 = 1, Freq = mean(all_data$imp_quan_cci[all_data$imp_disruption_any == 1]), measure = "age")) # Disruption
table1 <- rbind(table1, data.frame(Var1 = "Charlson", Var2 = 1, Freq = mean(all_data$imp_quan_cci), measure = "age")) # Total
# Elixhauser index
table1 <- rbind(table1, data.frame(Var1 = "Elixhauser", Var2 = 0, Freq = mean(all_data$imp_unw_eci[all_data$imp_disruption_any == 0]), measure = "age")) # No disruption
table1 <- rbind(table1, data.frame(Var1 = "Elixhauser", Var2 = 1, Freq = mean(all_data$imp_unw_eci[all_data$imp_disruption_any == 1]), measure = "age")) # Disruption
table1 <- rbind(table1, data.frame(Var1 = "Elixhauser", Var2 = 1, Freq = mean(all_data$imp_unw_eci), measure = "age")) # Total
# Asthma
hold <- data.frame(table(all_data$imp_asthma, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Asthma" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Cancer
hold <- data.frame(table(all_data$imp_cancer, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Cancer" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Diabetes
hold <- data.frame(table(all_data$imp_diabetes, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Diabetes" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Hypertension
hold <- data.frame(table(all_data$imp_hypertension, all_data$imp_disruption_any)) # Save frequency table
hold$measure <- "Hypertension" # Note measure
table1 <- rbind(table1, hold) # Join onto main table
# Save
write.csv(table1, "../../outputs/revised_summary_table_unweighted.csv") # Save
rm(hold, table1) # Tidy
# Weighted tables
# Define survey design
disrup <- all_data[all_data$imp_disruption_any == 1,] # Subset into people who were disrupted
wgt_disrp <- svydesign(id = ~LLC_0009_stud_id, weights = ~weight, strata = ~strata, fpc = ~fpc, nest = TRUE, survey.lonely.psu = "adjust", data = disrup) # Do survey design for above
nodisrup <- all_data[all_data$imp_disruption_any == 0,] # Subset into people who were not disrupted
wgt_nodisrp <- svydesign(id = ~LLC_0009_stud_id, weights = ~weight, strata = ~strata, fpc = ~fpc, nest = TRUE, survey.lonely.psu = "adjust", data = nodisrup)
# Age
table1w <- data.frame(svymean(disrup$imp_age, wgt_disrp)) # Generate statistics - do for disruption first, then no disruption
table1w$measure <- "Age" # Note measure
table1w$exposure <- "Disruption" # Note exposure (disruption)
hold <- data.frame(svymean(nodisrup$imp_age, wgt_nodisrp)) # Generate statistics - do for disruption first, then no disruption
hold$measure <- "Age" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(all_data$imp_age, wgt)) # Generate statistics - overall
hold$measure <- "Age" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Sex
hold <- data.frame(svymean(~factor(disrup$imp_sex), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Sex" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_sex), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Sex" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_sex), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Sex" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Ethnicity
hold <- data.frame(svymean(disrup$imp_not_white, wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Not white" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(nodisrup$imp_not_white, wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Not white" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_not_white), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Not white" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Tenure
hold <- data.frame(svymean(disrup$imp_own_home, wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Tenure" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(nodisrup$imp_own_home, wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Tenure" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_own_home), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Tenure" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Self-rated health
hold <- data.frame(svymean(~factor(disrup$imp_general_health), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Self-rated health" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_general_health), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Self-rated health" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_general_health), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Self-rated health" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# IMD
hold <- data.frame(svymean(~factor(disrup$imp_imd2019_income_q5), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "IMD" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_imd2019_income_q5), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "IMD" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_imd2019_income_q5), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "IMD" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Charlson
hold <- data.frame(svymean(disrup$imp_quan_cci, wgt_disrp)) # Generate statistics - do for disruption first, then no disruption
hold$measure <- "Charlson" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(nodisrup$imp_quan_cci, wgt_nodisrp)) # Generate statistics - do for disruption first, then no disruption
hold$measure <- "Charlson" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(all_data$imp_quan_cci, wgt)) # Generate statistics - overall
hold$measure <- "Charlson" # Note measure
hold$exposure <- "Total" # Note exposure (all cases - total)
table1w <- rbind(table1w, hold) # Join onto main table
# Elixhauser (unweighted)
hold <- data.frame(svymean(disrup$imp_unw_eci, wgt_disrp)) # Generate statistics - do for disruption first, then no disruption
hold$measure <- "Elixhauser" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(nodisrup$imp_unw_eci, wgt_nodisrp)) # Generate statistics - do for disruption first, then no disruption
hold$measure <- "Elixhauser" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(all_data$imp_unw_eci, wgt)) # Generate statistics - overall
hold$measure <- "Elixhauser" # Note measure
hold$exposure <- "Total" # Note exposure (all cases - total)
table1w <- rbind(table1w, hold) # Join onto main table
# Asthma
hold <- data.frame(svymean(~factor(disrup$imp_asthma), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Asthma" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_asthma), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Asthma" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_asthma), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Asthma" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Cancer
hold <- data.frame(svymean(~factor(disrup$imp_cancer), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Cancer" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_cancer), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Cancer" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_cancer), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Cancer" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Diabetes
hold <- data.frame(svymean(~factor(disrup$imp_diabetes), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Diabetes" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_diabetes), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Diabetes" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_diabetes), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Diabetes" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Hypertension
hold <- data.frame(svymean(~factor(disrup$imp_hypertension), wgt_disrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Hypertension" # Note measure
hold$exposure <- "Disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(nodisrup$imp_hypertension), wgt_nodisrp)) # Generate statistics (used mean here but is basically the proportion since binary) - do for disruption first, then no disruption
hold$measure <- "Hypertension" # Note measure
hold$exposure <- "No disruption" # Note exposure (disruption)
table1w <- rbind(table1w, hold) # Join onto main table
hold <- data.frame(svymean(~factor(all_data$imp_hypertension), wgt)) # Generate statistics (used mean here but is basically the proportion since binary) - all cases
hold$measure <- "Hypertension" # Note measure
hold$exposure <- "Total" # Note exposure (total - all cases)
table1w <- rbind(table1w, hold) # Join onto main table
# Save
write.csv(table1w, "../../outputs/revised_summary_table_weighted.csv") # Save
rm(hold, table1w) # Tidy
### 3. Checking impact of including COVID-19 into the model ###
# Note: I am not sure there is a conceptual justification for the inclusion of COVID-19 in the model (i.e., why having COVID-19 would lead to an avoidable hospitalisation for conditions that do not include COVID-19)
# I am checking only disruption overall since if there is noticeable overall impact, there is justification to go deeper
# All ambulatory care sensitive condition
model <- svyglm(`Ambulatory Care Sensitive All` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt)
summary(model) # Print summary of results
# Here it has no impact on the model really - COVID-19 infection has no association or an imprecise one. The effect size for disruption is hardly adjusted as a result.
table2 <- tidy(model, conf.int = TRUE) # Save key results
table2 <- table2[2,] # Extract only healthcare disruption variable
table2$model <- "All ACS - adj" # Note model name
# Any ambulatory care sensitive acute conditions
model_any_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt) # Adjusted
summary(model_any_b_a) # Print summary of results
hold <- tidy(model_any_b_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Any ambulatory care sensitive chronic conditions
model_any_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt) # Adjusted
summary(model_any_c_a) # Print summary of results
hold <- tidy(model_any_c_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# d: Any ambulatory care sensitive conditions
model_any_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt) # Adjusted
summary(model_any_d_a) # Print summary of results
hold <- tidy(model_any_d_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# e: Emergency Urgent Sensitive conditions
model_any_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt) # Adjusted
summary(model_any_e_a) # Print summary of results
hold <- tidy(model_any_e_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# f: Emergency Urgent Sensitive conditions
model_any_f_a <- svyglm(total_admissions ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_covid), data = all_data, family = "binomial", design = wgt) # Adjusted
summary(model_any_f_a) # Print summary of results
hold <- tidy(model_any_f_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
write.csv(table2, "../../outputs/regression_model1_withcovid.csv") # Save
rm(table2) # Tidy
### 4. Including whether people had an avoidable hospitalisation prior to the pandemic ###
# Load data
load(file = "S:/LLC_0009/data/Cleaned Cohorts/nhs_hes_1yearpre.RData") # 1 year pre 1st March 2020
hes$`Ambulatory Care Sensitive All` <- hes$`Ambulatory Care Sensitive Acute` + hes$`Ambulatory Care Sensitive Chronic` + hes$`Ambulatory Care Sensitive Vaccine-preventable`
# load(file = "S:/LLC_0009/data/Cleaned Cohorts/nhs_hes_2019.RData") # Only 2019
# Join onto main dataset
hold <- merge(all_data, hes, by.x = "LLC_0009_stud_id", by.y = "llc_0009_stud_id", all.x = TRUE)
hold <- hold[!is.na(hold$LLC_0009_stud_id),] # Above creates some blank IDs so lets drop them
# Count numbers who had a previous admission for each outcome
nrow(hold[!is.na (hold$`Ambulatory Care Sensitive All.y`) & hold$`Ambulatory Care Sensitive All.y` >= 1,])
nrow(hold[!is.na (hold$`Ambulatory Care Sensitive Acute.y`) & hold$`Ambulatory Care Sensitive Acute.y` >= 1,])
nrow(hold[!is.na (hold$`Ambulatory Care Sensitive Chronic.y`) & hold$`Ambulatory Care Sensitive Chronic.y` >= 1,])
nrow(hold[!is.na (hold$`Ambulatory Care Sensitive Vaccine-preventable.y`) & hold$`Ambulatory Care Sensitive Vaccine-preventable.y` >= 1,])
nrow(hold[!is.na (hold$`Emergency Urgent Care Sensitive .y`) & hold$`Emergency Urgent Care Sensitive .y` >= 1,])
nrow(hold[!is.na (hold$`total_admissions.y`) & hold$`total_admissions.y` >= 1,])
# Clean data
hold$`Ambulatory Care Sensitive All.y`[is.na(hold$`Ambulatory Care Sensitive All.y`)] <- 0 # Missing data means has not had one
hold$`Ambulatory Care Sensitive All.y`[hold$`Ambulatory Care Sensitive All.y` > 1] <- 1 # Change into binary
hold$`Ambulatory Care Sensitive Acute.y`[is.na(hold$`Ambulatory Care Sensitive Acute.y`)] <- 0 # Repeat one by one
hold$`Ambulatory Care Sensitive Acute.y`[hold$`Ambulatory Care Sensitive Acute.y` > 1] <- 1
hold$`Ambulatory Care Sensitive Chronic.y`[is.na(hold$`Ambulatory Care Sensitive Chronic.y`)] <- 0
hold$`Ambulatory Care Sensitive Chronic.y`[hold$`Ambulatory Care Sensitive Chronic.y` > 1] <- 1
hold$`Ambulatory Care Sensitive Vaccine-preventable.y`[is.na(hold$`Ambulatory Care Sensitive Vaccine-preventable.y`)] <- 0
hold$`Ambulatory Care Sensitive Vaccine-preventable.y`[hold$`Ambulatory Care Sensitive Vaccine-preventable.y` > 1] <- 1
hold$`Emergency Urgent Care Sensitive .y`[is.na(hold$`Emergency Urgent Care Sensitive .y`)] <- 0
hold$`Emergency Urgent Care Sensitive .y`[hold$`Emergency Urgent Care Sensitive .y` > 1] <- 1
hold$`total_admissions.y`[is.na(hold$`total_admissions.y`)] <- 0
hold$`total_admissions.y`[hold$`total_admissions.y` > 1] <- 1
# Calculate sample weights
wgt_new <- svydesign(id = ~LLC_0009_stud_id, weights = ~weight, strata = ~strata, fpc = ~fpc, nest = TRUE, survey.lonely.psu = "adjust", data = hold)
## 1. Any disruption
## All ambulatory care sensitive ##
model <- svyglm(`Ambulatory Care Sensitive All.x` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive All.x`), data = hold, family = "binomial", design = wgt_new) # Run model
table3 <- tidy(model, conf.int = TRUE) # Save key results
table3 <- table3[2,] # Extract only healthcare disruption variable
table3$model <- "All ACS - previous adm" # Note model name
# Acute ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Acute.x` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Acute.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2,] # Extract only healthcare disruption variable
temp$model <- "Acute ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Chronic ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Chronic.x` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Chronic.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2,] # Extract only healthcare disruption variable
temp$model <- "Chronic ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Vaccine-preventable ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable.x` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Vaccine-preventable.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2,] # Extract only healthcare disruption variable
temp$model <- "Vaccine ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Emergency Urgent Care Sensitive conditions
model <- svyglm(`Emergency Urgent Care Sensitive .x` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Emergency Urgent Care Sensitive .y`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2,] # Extract only healthcare disruption variable
temp$model <- "EUCS ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Total admissions
model <- svyglm(`total_admissions.y` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`total_admissions.y`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2,] # Extract only healthcare disruption variable
temp$model <- "Total adm - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
write.csv(table3, file = "S:/LLC_0009/outputs/regression_model1_prevadm.csv") # Save
rm(table3)
## 2. Disruption type ##
## All ambulatory care sensitive ##
model <- svyglm(`Ambulatory Care Sensitive All.x` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive All.x`), data = hold, family = "binomial", design = wgt_new) # Run model
table3 <- tidy(model, conf.int = TRUE) # Save key results
table3 <- table3[2:4,] # Extract only healthcare disruption variable
table3$model <- "All ACS - previous adm" # Note model name
# Acute ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Acute.x` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Acute.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2:4,] # Extract only healthcare disruption variable
temp$model <- "Acute ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Chronic ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Chronic.x` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Chronic.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2:4,] # Extract only healthcare disruption variable
temp$model <- "Chronic ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Vaccine-preventable ambulatory care sensitive acute conditions
model <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable.x` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Ambulatory Care Sensitive Vaccine-preventable.x`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2:4,] # Extract only healthcare disruption variable
temp$model <- "Vaccine ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Emergency Urgent Care Sensitive conditions
model <- svyglm(`Emergency Urgent Care Sensitive .x` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`Emergency Urgent Care Sensitive .y`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2:4,] # Extract only healthcare disruption variable
temp$model <- "EUCS ACS - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
# Total admissions
model <- svyglm(`total_admissions.y` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension) + factor(`total_admissions.y`), data = hold, family = "binomial", design = wgt_new) # Run model
temp <- tidy(model, conf.int = TRUE) # Save key results
temp <- temp[2:4,] # Extract only healthcare disruption variable
temp$model <- "Total adm - previous adm" # Note model name
table3 <- rbind(table3, temp) # Join to main table
write.csv(table3, file = "S:/LLC_0009/outputs/regression_model2_prevadm.csv") # Save
rm(table3)
### 5. Complete case analysis ###
# Data cleaning
all_data$age_squared <- all_data$age^2
# Part 1: Any type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_any_a_u <- svyglm(`Ambulatory Care Sensitive All` ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
table4 <- tidy(model_any_a_u, conf.int = TRUE) # Save key results
table4 <- table4[2,] # Extract only healthcare disruption variable
table4$model <- "All ACS - unadj" # Note model name
model_any_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_a_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "All ACS - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
# Model b: Any ambulatory care sensitive acute conditions
model_any_b_u <- svyglm(`Ambulatory Care Sensitive Acute` ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_any_b_u, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - unadj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
model_any_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_b_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
# Model c: Any ambulatory care sensitive chronic conditions
model_any_c_u <- svyglm(`Ambulatory Care Sensitive Chronic` ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_any_c_u, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - unadj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
model_any_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_c_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
# Model d: Any ambulatory care sensitive conditions
model_any_d_u <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_any_d_u, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - unadj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
model_any_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_d_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_any_e_u <- svyglm(`Emergency Urgent Care Sensitive ` ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_any_e_u, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "EUCS - unadj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
model_any_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_e_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
# Model f: Emergency Urgent Sensitive conditions
model_any_f_u <- svyglm(total_admissions ~ disruption_any, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_any_f_u, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Any adm - unadj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
model_any_f_a <- svyglm(total_admissions ~ disruption_any + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_f_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table4 <- rbind(table4, hold) # Join to main table
write.csv(table4, "../../outputs/regression_model1_completecase.csv") # Save
rm(table4) # Tidy
# Part 2: Type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_type_a_u <- svyglm(`Ambulatory Care Sensitive All` ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
table5 <- tidy(model_type_a_u, conf.int = TRUE) # Save key results
table5 <- table5[2:4,] # Extract only healthcare disruption variable
table5$model <- "All ACS - unadj" # Note model name
model_type_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_a_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "All ACS - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
# Model b: Acute ambulatory care sensitive acute conditions
model_type_b_u <- svyglm(`Ambulatory Care Sensitive Acute` ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_type_b_u, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - unadj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
model_type_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_b_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
# Model c: Chronic ambulatory care sensitive chronic conditions
model_type_c_u <- svyglm(`Ambulatory Care Sensitive Chronic` ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_type_c_u, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - unadj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
model_type_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_c_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
# Model d: Vaccinhe preventable ambulatory care sensitive conditions
model_type_d_u <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_type_d_u, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - unadj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
model_type_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_d_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_type_e_u <- svyglm(`Emergency Urgent Care Sensitive ` ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_type_e_u, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "EUCS - unadj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
model_type_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_e_a, conf.int = TRUE) # Save key results
# If unhappy, then can do manually with confint(model_type_e_a, parm = "disruption_appointments")
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
# Model f: Any hospital admission
model_type_f_u <- svyglm(total_admissions ~ disruption_appointments + disruption_medications + disruption_procedures, data = all_data, family = "binomial", design = wgt) # Unadjusted
hold <- tidy(model_type_f_u, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Any adm - unadj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
model_type_f_a <- svyglm(total_admissions ~ disruption_appointments + disruption_medications + disruption_procedures + factor(sex) + age + age_squared + factor(not_white) + factor(own_home) + factor(general_health) + factor(imd2019_income_q5) + factor(cohort) + imp_quan_cci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_f_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table5 <- rbind(table5, hold) # Join to main table
write.csv(table5, file = "S:/LLC_0009/outputs/regression_model2_completecase.csv") # Save
### 6. Use Elixhauser index instead of Charlson ###
# Part 1: Any type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_any_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
table2 <- tidy(model_any_a_a, conf.int = TRUE) # Save key results
table2 <- table2[2,] # Extract only healthcare disruption variable
table2$model <- "All ACS - adj" # Note model name
# Model b: Any ambulatory care sensitive acute conditions
model_any_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_b_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model c: Any ambulatory care sensitive chronic conditions
model_any_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_c_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model d: Any ambulatory care sensitive conditions
model_any_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_d_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_any_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_e_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model f: Emergency Urgent Sensitive conditions
model_any_f_a <- svyglm(total_admissions ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_f_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
write.csv(table2, "../../outputs/regression_model1_elix.csv") # Save
rm(table2) # Tidy
# Part 2: Type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_type_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
table3 <- tidy(model_type_a_a, conf.int = TRUE) # Save key results
table3 <- table3[2:4,] # Extract only healthcare disruption variable
table3$model <- "All ACS - adj" # Note model name
# Model b: Acute ambulatory care sensitive acute conditions
model_type_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_b_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model c: Chronic ambulatory care sensitive chronic conditions
model_type_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_c_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model d: Vaccinhe preventable ambulatory care sensitive conditions
model_type_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_d_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_type_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_e_a, conf.int = TRUE) # Save key results
# If unhappy, then can do manually with confint(model_type_e_a, parm = "disruption_appointments")
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model f: Any hospital admission
model_type_f_a <- svyglm(total_admissions ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_unw_eci, data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_f_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
write.csv(table3, file = "S:/LLC_0009/outputs/regression_model2_elix.csv") # Save
### 7. Include four measurable health conditions ###
# Part 1: Any type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_any_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
table2 <- tidy(model_any_a_a, conf.int = TRUE) # Save key results
table2 <- table2[2,] # Extract only healthcare disruption variable
table2$model <- "All ACS - adj" # Note model name
# Model b: Any ambulatory care sensitive acute conditions
model_any_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_b_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model c: Any ambulatory care sensitive chronic conditions
model_any_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_c_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model d: Any ambulatory care sensitive conditions
model_any_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_d_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_any_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_e_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
# Model f: Emergency Urgent Sensitive conditions
model_any_f_a <- svyglm(total_admissions ~ imp_disruption_any + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_any_f_a, conf.int = TRUE) # Save key results
hold <- hold[2,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table2 <- rbind(table2, hold) # Join to main table
write.csv(table2, "../../outputs/regression_model1_hcond.csv") # Save
rm(table2) # Tidy
# Part 2: Type of disruption #
# Model a: Any ambulatory care sensitive conditions
model_type_a_a <- svyglm(`Ambulatory Care Sensitive All` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
table3 <- tidy(model_type_a_a, conf.int = TRUE) # Save key results
table3 <- table3[2:4,] # Extract only healthcare disruption variable
table3$model <- "All ACS - adj" # Note model name
# Model b: Acute ambulatory care sensitive acute conditions
model_type_b_a <- svyglm(`Ambulatory Care Sensitive Acute` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_b_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Acute ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model c: Chronic ambulatory care sensitive chronic conditions
model_type_c_a <- svyglm(`Ambulatory Care Sensitive Chronic` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_c_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Chronic ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model d: Vaccinhe preventable ambulatory care sensitive conditions
model_type_d_a <- svyglm(`Ambulatory Care Sensitive Vaccine-preventable` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_d_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Vaccine preventable ACS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model e: Emergency Urgent Sensitive conditions
model_type_e_a <- svyglm(`Emergency Urgent Care Sensitive ` ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_e_a, conf.int = TRUE) # Save key results
# If unhappy, then can do manually with confint(model_type_e_a, parm = "disruption_appointments")
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "EUCS - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
# Model f: Any hospital admission
model_type_f_a <- svyglm(total_admissions ~ imp_disruption_appointments + imp_disruption_medications + imp_disruption_procedures + factor(imp_sex) + imp_age + imp_age2 + factor(imp_not_white) + factor(imp_own_home) + factor(imp_general_health) + factor(imp_imd2019_income_q5) + factor(cohort) + imp_quan_cci + factor(imp_asthma) + factor(imp_cancer) + factor(imp_diabetes) + factor(imp_hypertension), data = all_data, family = "binomial", design = wgt) # Adjusted
hold <- tidy(model_type_f_a, conf.int = TRUE) # Save key results
hold <- hold[2:4,] # Extract only healthcare disruption variable
hold$model <- "Any adm - adj" # Note model name
table3 <- rbind(table3, hold) # Join to main table
write.csv(table3, file = "S:/LLC_0009/outputs/regression_model2_hcond.csv") # Save