Main Analysis

Author

Jacob Simmering

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.1
✔ tibble  3.2.1     ✔ dplyr   1.1.2
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(survival)
library(tableone)
library(gtsummary)

Data Loading and Processing

if (Sys.info()["sysname"] == "Darwin") {
  model_data <- read_rds("/Volumes/lss_jsimmeri/als/model_data.rds")
} else {
  model_data <- read_rds("/Shared/lss_jsimmeri/als/model_data.rds")
}
model_data <- model_data |>
  mutate(
    age = first_year - dobyr,
    female = sex == 1,
    stratum = as.numeric(as.factor(glue::glue("{first_year}-{last_year}-{dobyr}-{sex}")))
  ) |>
  mutate(any_sx = motor | bulbar,
         n_groups = motor + bulbar,
         n_bulbar = speech + swallowing,
         n_motor = strength + gait + involuntary_movement + pain + other + falls,
         n_total = speech + swallowing + strength + gait + involuntary_movement + pain + other + falls)

Data Summary

First, the data summary by ALS status:

all_vars <- c(
  "age", "female", 
  "first_year", "last_year",
  "rate_outpatient_visits", "intensity_outpatient_visits_dx",
  "rate_inpatient_stays", "intensity_inpatient_stays_los",
  "elix_CHF", "elix_Valvular", "elix_PHTN", "elix_PVD", "elix_HTN",
  "elix_HTNcx", "elix_Paralysis", "elix_NeuroOther", "elix_Pulmonary", "elix_DM",
  "elix_DMcx", "elix_Hypothyroid", "elix_Renal", "elix_Liver", "elix_PUD", 
  "elix_HIV", "elix_Lymphoma", "elix_Mets", "elix_Tumor", "elix_Rheumatic", 
  "elix_Coagulopathy", "elix_Obesity", "elix_WeightLoss", "elix_FluidsLytes", "elix_BloodLoss", 
  "elix_Anemia", "elix_Alcohol", "elix_Drugs", "elix_Psychoses", "elix_Depression", 
  "lives_in_msa",
  "any_sx", "motor", "bulbar",
  "n_groups", "n_bulbar", "n_motor", "n_total",
  "speech", "swallowing", 
  "strength", "gait", "involuntary_movement", "pain", "other", "falls")
factor_vars <- c("n_groups", "n_bulbar", "n_motor", "n_total")
nonnormal_vars <- c("age", "first_year", "last_year", "rate_outpatient_visits", 
  "intensity_outpatient_visits_dx", "rate_inpatient_stays", 
  "intensity_inpatient_stays_los")

CreateTableOne(
  data = model_data,
  vars = all_vars,
  factorVars = factor_vars,
  strata = c("als")
) |>
  print(nonnormal = nonnormal_vars, smd = TRUE)
                                               Stratified by als
                                                FALSE                     
  n                                               96126                   
  age (median [IQR])                              56.00 [47.00, 65.00]    
  female = TRUE (%)                               54325 (56.5)            
  first_year (median [IQR])                     2007.00 [2003.00, 2010.00]
  last_year (median [IQR])                      2012.00 [2008.00, 2015.00]
  rate_outpatient_visits (median [IQR])            7.10 [2.89, 14.56]     
  intensity_outpatient_visits_dx (median [IQR])    1.51 [1.21, 2.03]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.12]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 1.50]      
  elix_CHF = TRUE (%)                              8899 ( 9.3)            
  elix_Valvular = TRUE (%)                        12631 (13.1)            
  elix_PHTN = TRUE (%)                             3107 ( 3.2)            
  elix_PVD = TRUE (%)                             12089 (12.6)            
  elix_HTN = TRUE (%)                             48410 (50.4)            
  elix_HTNcx = TRUE (%)                           11065 (11.5)            
  elix_Paralysis = TRUE (%)                        2065 ( 2.1)            
  elix_NeuroOther = TRUE (%)                       9944 (10.3)            
  elix_Pulmonary = TRUE (%)                       21899 (22.8)            
  elix_DM = TRUE (%)                              20001 (20.8)            
  elix_DMcx = TRUE (%)                             8413 ( 8.8)            
  elix_Hypothyroid = TRUE (%)                     13543 (14.1)            
  elix_Renal = TRUE (%)                            6213 ( 6.5)            
  elix_Liver = TRUE (%)                            4626 ( 4.8)            
  elix_PUD = TRUE (%)                               491 ( 0.5)            
  elix_HIV = TRUE (%)                               188 ( 0.2)            
  elix_Lymphoma = TRUE (%)                         1326 ( 1.4)            
  elix_Mets = TRUE (%)                             3508 ( 3.6)            
  elix_Tumor = TRUE (%)                           12044 (12.5)            
  elix_Rheumatic = TRUE (%)                        5852 ( 6.1)            
  elix_Coagulopathy = TRUE (%)                     3999 ( 4.2)            
  elix_Obesity = TRUE (%)                         11063 (11.5)            
  elix_WeightLoss = TRUE (%)                       5374 ( 5.6)            
  elix_FluidsLytes = TRUE (%)                     13387 (13.9)            
  elix_BloodLoss = TRUE (%)                        2005 ( 2.1)            
  elix_Anemia = TRUE (%)                          16207 (16.9)            
  elix_Alcohol = TRUE (%)                          2022 ( 2.1)            
  elix_Drugs = TRUE (%)                            1292 ( 1.3)            
  elix_Psychoses = TRUE (%)                        7433 ( 7.7)            
  elix_Depression = TRUE (%)                      11856 (12.3)            
  lives_in_msa = TRUE (%)                         81245 (84.5)            
  any_sx = TRUE (%)                               48713 (50.7)            
  motor = TRUE (%)                                47089 (49.0)            
  bulbar = TRUE (%)                                7679 ( 8.0)            
  n_groups (%)                                                            
     0                                            47413 (49.3)            
     1                                            42658 (44.4)            
     2                                             6055 ( 6.3)            
  n_bulbar (%)                                                            
     0                                            88447 (92.0)            
     1                                             7273 ( 7.6)            
     2                                              406 ( 0.4)            
  n_motor (%)                                                             
     0                                            49037 (51.0)            
     1                                            29389 (30.6)            
     2                                             9280 ( 9.7)            
     3                                             4885 ( 5.1)            
     4                                             2391 ( 2.5)            
     5                                              944 ( 1.0)            
     6                                              200 ( 0.2)            
  n_total (%)                                                             
     0                                            47413 (49.3)            
     1                                            28523 (29.7)            
     2                                            10312 (10.7)            
     3                                             5302 ( 5.5)            
     4                                             2596 ( 2.7)            
     5                                             1296 ( 1.3)            
     6                                              541 ( 0.6)            
     7                                              134 ( 0.1)            
     8                                                9 ( 0.0)            
  speech = TRUE (%)                                6620 ( 6.9)            
  swallowing = TRUE (%)                            1465 ( 1.5)            
  strength = TRUE (%)                              5028 ( 5.2)            
  gait = TRUE (%)                                  8373 ( 8.7)            
  involuntary_movement = TRUE (%)                  6078 ( 6.3)            
  pain = TRUE (%)                                 41847 (43.5)            
  other = TRUE (%)                                14195 (14.8)            
  falls = TRUE (%)                                 2567 ( 2.7)            
                                               Stratified by als
                                                TRUE                      
  n                                               19226                   
  age (median [IQR])                              56.00 [47.00, 65.00]    
  female = TRUE (%)                               10865 (56.5)            
  first_year (median [IQR])                     2007.00 [2003.00, 2010.00]
  last_year (median [IQR])                      2012.00 [2008.00, 2015.00]
  rate_outpatient_visits (median [IQR])           13.66 [7.26, 24.11]     
  intensity_outpatient_visits_dx (median [IQR])    1.61 [1.29, 2.13]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.25]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 2.50]      
  elix_CHF = TRUE (%)                              1771 ( 9.2)            
  elix_Valvular = TRUE (%)                         3090 (16.1)            
  elix_PHTN = TRUE (%)                              755 ( 3.9)            
  elix_PVD = TRUE (%)                              3035 (15.8)            
  elix_HTN = TRUE (%)                             10604 (55.2)            
  elix_HTNcx = TRUE (%)                            2338 (12.2)            
  elix_Paralysis = TRUE (%)                        2219 (11.5)            
  elix_NeuroOther = TRUE (%)                       7838 (40.8)            
  elix_Pulmonary = TRUE (%)                        5312 (27.6)            
  elix_DM = TRUE (%)                               3958 (20.6)            
  elix_DMcx = TRUE (%)                             1639 ( 8.5)            
  elix_Hypothyroid = TRUE (%)                      3550 (18.5)            
  elix_Renal = TRUE (%)                            1052 ( 5.5)            
  elix_Liver = TRUE (%)                            1079 ( 5.6)            
  elix_PUD = TRUE (%)                               127 ( 0.7)            
  elix_HIV = TRUE (%)                                51 ( 0.3)            
  elix_Lymphoma = TRUE (%)                          371 ( 1.9)            
  elix_Mets = TRUE (%)                              386 ( 2.0)            
  elix_Tumor = TRUE (%)                            2322 (12.1)            
  elix_Rheumatic = TRUE (%)                        2130 (11.1)            
  elix_Coagulopathy = TRUE (%)                     1011 ( 5.3)            
  elix_Obesity = TRUE (%)                          2218 (11.5)            
  elix_WeightLoss = TRUE (%)                       2344 (12.2)            
  elix_FluidsLytes = TRUE (%)                      3348 (17.4)            
  elix_BloodLoss = TRUE (%)                         397 ( 2.1)            
  elix_Anemia = TRUE (%)                           4267 (22.2)            
  elix_Alcohol = TRUE (%)                           491 ( 2.6)            
  elix_Drugs = TRUE (%)                             397 ( 2.1)            
  elix_Psychoses = TRUE (%)                        2327 (12.1)            
  elix_Depression = TRUE (%)                       3617 (18.8)            
  lives_in_msa = TRUE (%)                         16726 (87.0)            
  any_sx = TRUE (%)                               16097 (83.7)            
  motor = TRUE (%)                                15208 (79.1)            
  bulbar = TRUE (%)                                5561 (28.9)            
  n_groups (%)                                                            
     0                                             3129 (16.3)            
     1                                            11425 (59.4)            
     2                                             4672 (24.3)            
  n_bulbar (%)                                                            
     0                                            13665 (71.1)            
     1                                             5194 (27.0)            
     2                                              367 ( 1.9)            
  n_motor (%)                                                             
     0                                             4018 (20.9)            
     1                                             4527 (23.5)            
     2                                             3343 (17.4)            
     3                                             3572 (18.6)            
     4                                             2531 (13.2)            
     5                                             1053 ( 5.5)            
     6                                              182 ( 0.9)            
  n_total (%)                                                             
     0                                             3129 (16.3)            
     1                                             4254 (22.1)            
     2                                             3481 (18.1)            
     3                                             3451 (17.9)            
     4                                             2663 (13.9)            
     5                                             1523 ( 7.9)            
     6                                              578 ( 3.0)            
     7                                              142 ( 0.7)            
     8                                                5 ( 0.0)            
  speech = TRUE (%)                                5356 (27.9)            
  swallowing = TRUE (%)                             572 ( 3.0)            
  strength = TRUE (%)                              6749 (35.1)            
  gait = TRUE (%)                                  5761 (30.0)            
  involuntary_movement = TRUE (%)                  4561 (23.7)            
  pain = TRUE (%)                                 11147 (58.0)            
  other = TRUE (%)                                 9050 (47.1)            
  falls = TRUE (%)                                 1142 ( 5.9)            
                                               Stratified by als
                                                p      test    SMD   
  n                                                                  
  age (median [IQR])                             0.993 nonnorm <0.001
  female = TRUE (%)                              1.000         <0.001
  first_year (median [IQR])                      0.999 nonnorm <0.001
  last_year (median [IQR])                       0.997 nonnorm <0.001
  rate_outpatient_visits (median [IQR])         <0.001 nonnorm  0.465
  intensity_outpatient_visits_dx (median [IQR]) <0.001 nonnorm  0.196
  rate_inpatient_stays (median [IQR])           <0.001 nonnorm  0.168
  intensity_inpatient_stays_los (median [IQR])  <0.001 nonnorm  0.127
  elix_CHF = TRUE (%)                            0.851          0.002
  elix_Valvular = TRUE (%)                      <0.001          0.083
  elix_PHTN = TRUE (%)                          <0.001          0.037
  elix_PVD = TRUE (%)                           <0.001          0.092
  elix_HTN = TRUE (%)                           <0.001          0.096
  elix_HTNcx = TRUE (%)                          0.011          0.020
  elix_Paralysis = TRUE (%)                     <0.001          0.379
  elix_NeuroOther = TRUE (%)                    <0.001          0.744
  elix_Pulmonary = TRUE (%)                     <0.001          0.112
  elix_DM = TRUE (%)                             0.498          0.005
  elix_DMcx = TRUE (%)                           0.315          0.008
  elix_Hypothyroid = TRUE (%)                   <0.001          0.119
  elix_Renal = TRUE (%)                         <0.001          0.042
  elix_Liver = TRUE (%)                         <0.001          0.036
  elix_PUD = TRUE (%)                            0.011          0.020
  elix_HIV = TRUE (%)                            0.064          0.015
  elix_Lymphoma = TRUE (%)                      <0.001          0.043
  elix_Mets = TRUE (%)                          <0.001          0.099
  elix_Tumor = TRUE (%)                          0.085          0.014
  elix_Rheumatic = TRUE (%)                     <0.001          0.179
  elix_Coagulopathy = TRUE (%)                  <0.001          0.052
  elix_Obesity = TRUE (%)                        0.923          0.001
  elix_WeightLoss = TRUE (%)                    <0.001          0.234
  elix_FluidsLytes = TRUE (%)                   <0.001          0.096
  elix_BloodLoss = TRUE (%)                      0.875          0.001
  elix_Anemia = TRUE (%)                        <0.001          0.135
  elix_Alcohol = TRUE (%)                       <0.001          0.030
  elix_Drugs = TRUE (%)                         <0.001          0.056
  elix_Psychoses = TRUE (%)                     <0.001          0.147
  elix_Depression = TRUE (%)                    <0.001          0.179
  lives_in_msa = TRUE (%)                       <0.001          0.071
  any_sx = TRUE (%)                             <0.001          0.752
  motor = TRUE (%)                              <0.001          0.661
  bulbar = TRUE (%)                             <0.001          0.560
  n_groups (%)                                  <0.001          0.831
     0                                                               
     1                                                               
     2                                                               
  n_bulbar (%)                                  <0.001          0.561
     0                                                               
     1                                                               
     2                                                               
  n_motor (%)                                   <0.001          0.910
     0                                                               
     1                                                               
     2                                                               
     3                                                               
     4                                                               
     5                                                               
     6                                                               
  n_total (%)                                   <0.001          1.008
     0                                                               
     1                                                               
     2                                                               
     3                                                               
     4                                                               
     5                                                               
     6                                                               
     7                                                               
     8                                                               
  speech = TRUE (%)                             <0.001          0.576
  swallowing = TRUE (%)                         <0.001          0.098
  strength = TRUE (%)                           <0.001          0.802
  gait = TRUE (%)                               <0.001          0.559
  involuntary_movement = TRUE (%)               <0.001          0.502
  pain = TRUE (%)                               <0.001          0.292
  other = TRUE (%)                              <0.001          0.746
  falls = TRUE (%)                              <0.001          0.162

And then by ALS and whether they live in an MSA:

CreateTableOne(
  data = model_data,
  vars = all_vars,
  factorVars = factor_vars,
  strata = c("als", "lives_in_msa")
) |>
  print(nonnormal = nonnormal_vars, smd = TRUE)
                                               Stratified by als:lives_in_msa
                                                FALSE:FALSE               
  n                                               14881                   
  age (median [IQR])                              57.00 [48.00, 65.00]    
  female = TRUE (%)                                8636 (58.0)            
  first_year (median [IQR])                     2007.00 [2002.00, 2010.00]
  last_year (median [IQR])                      2011.00 [2008.00, 2014.00]
  rate_outpatient_visits (median [IQR])            6.86 [2.83, 13.91]     
  intensity_outpatient_visits_dx (median [IQR])    1.51 [1.22, 2.04]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.14]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 1.50]      
  elix_CHF = TRUE (%)                              1310 ( 8.8)            
  elix_Valvular = TRUE (%)                         1660 (11.2)            
  elix_PHTN = TRUE (%)                              439 ( 3.0)            
  elix_PVD = TRUE (%)                              1724 (11.6)            
  elix_HTN = TRUE (%)                              7787 (52.3)            
  elix_HTNcx = TRUE (%)                            1433 ( 9.6)            
  elix_Paralysis = TRUE (%)                         305 ( 2.0)            
  elix_NeuroOther = TRUE (%)                       1432 ( 9.6)            
  elix_Pulmonary = TRUE (%)                        3524 (23.7)            
  elix_DM = TRUE (%)                               3025 (20.3)            
  elix_DMcx = TRUE (%)                             1125 ( 7.6)            
  elix_Hypothyroid = TRUE (%)                      1987 (13.4)            
  elix_Renal = TRUE (%)                             822 ( 5.5)            
  elix_Liver = TRUE (%)                             621 ( 4.2)            
  elix_PUD = TRUE (%)                                65 ( 0.4)            
  elix_HIV = TRUE (%)                                 8 ( 0.1)            
  elix_Lymphoma = TRUE (%)                          163 ( 1.1)            
  elix_Mets = TRUE (%)                              534 ( 3.6)            
  elix_Tumor = TRUE (%)                            1775 (11.9)            
  elix_Rheumatic = TRUE (%)                         891 ( 6.0)            
  elix_Coagulopathy = TRUE (%)                      557 ( 3.7)            
  elix_Obesity = TRUE (%)                          1613 (10.8)            
  elix_WeightLoss = TRUE (%)                        818 ( 5.5)            
  elix_FluidsLytes = TRUE (%)                      1977 (13.3)            
  elix_BloodLoss = TRUE (%)                         276 ( 1.9)            
  elix_Anemia = TRUE (%)                           2094 (14.1)            
  elix_Alcohol = TRUE (%)                           280 ( 1.9)            
  elix_Drugs = TRUE (%)                             173 ( 1.2)            
  elix_Psychoses = TRUE (%)                         954 ( 6.4)            
  elix_Depression = TRUE (%)                       1763 (11.8)            
  lives_in_msa = TRUE (%)                             0 ( 0.0)            
  any_sx = TRUE (%)                                7381 (49.6)            
  motor = TRUE (%)                                 7123 (47.9)            
  bulbar = TRUE (%)                                1098 ( 7.4)            
  n_groups (%)                                                            
     0                                             7500 (50.4)            
     1                                             6541 (44.0)            
     2                                              840 ( 5.6)            
  n_bulbar (%)                                                            
     0                                            13783 (92.6)            
     1                                             1045 ( 7.0)            
     2                                               53 ( 0.4)            
  n_motor (%)                                                             
     0                                             7758 (52.1)            
     1                                             4545 (30.5)            
     2                                             1450 ( 9.7)            
     3                                              713 ( 4.8)            
     4                                              286 ( 1.9)            
     5                                              102 ( 0.7)            
     6                                               27 ( 0.2)            
  n_total (%)                                                             
     0                                             7500 (50.4)            
     1                                             4453 (29.9)            
     2                                             1585 (10.7)            
     3                                              771 ( 5.2)            
     4                                              355 ( 2.4)            
     5                                              129 ( 0.9)            
     6                                               66 ( 0.4)            
     7                                               22 ( 0.1)            
     8                                                0 ( 0.0)            
  speech = TRUE (%)                                 948 ( 6.4)            
  swallowing = TRUE (%)                             203 ( 1.4)            
  strength = TRUE (%)                               666 ( 4.5)            
  gait = TRUE (%)                                  1079 ( 7.3)            
  involuntary_movement = TRUE (%)                   923 ( 6.2)            
  pain = TRUE (%)                                  6309 (42.4)            
  other = TRUE (%)                                 2038 (13.7)            
  falls = TRUE (%)                                  385 ( 2.6)            
                                               Stratified by als:lives_in_msa
                                                TRUE:FALSE                
  n                                                2500                   
  age (median [IQR])                              57.00 [49.00, 65.00]    
  female = TRUE (%)                                1438 (57.5)            
  first_year (median [IQR])                     2006.00 [2002.00, 2010.00]
  last_year (median [IQR])                      2011.00 [2008.00, 2014.00]
  rate_outpatient_visits (median [IQR])           12.84 [6.75, 22.02]     
  intensity_outpatient_visits_dx (median [IQR])    1.66 [1.32, 2.19]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.23]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 2.00]      
  elix_CHF = TRUE (%)                               235 ( 9.4)            
  elix_Valvular = TRUE (%)                          329 (13.2)            
  elix_PHTN = TRUE (%)                              101 ( 4.0)            
  elix_PVD = TRUE (%)                               362 (14.5)            
  elix_HTN = TRUE (%)                              1466 (58.6)            
  elix_HTNcx = TRUE (%)                             230 ( 9.2)            
  elix_Paralysis = TRUE (%)                         266 (10.6)            
  elix_NeuroOther = TRUE (%)                       1015 (40.6)            
  elix_Pulmonary = TRUE (%)                         726 (29.0)            
  elix_DM = TRUE (%)                                472 (18.9)            
  elix_DMcx = TRUE (%)                              163 ( 6.5)            
  elix_Hypothyroid = TRUE (%)                       412 (16.5)            
  elix_Renal = TRUE (%)                             119 ( 4.8)            
  elix_Liver = TRUE (%)                             119 ( 4.8)            
  elix_PUD = TRUE (%)                                16 ( 0.6)            
  elix_HIV = TRUE (%)                                 0 ( 0.0)            
  elix_Lymphoma = TRUE (%)                           41 ( 1.6)            
  elix_Mets = TRUE (%)                               37 ( 1.5)            
  elix_Tumor = TRUE (%)                             259 (10.4)            
  elix_Rheumatic = TRUE (%)                         279 (11.2)            
  elix_Coagulopathy = TRUE (%)                      115 ( 4.6)            
  elix_Obesity = TRUE (%)                           282 (11.3)            
  elix_WeightLoss = TRUE (%)                        322 (12.9)            
  elix_FluidsLytes = TRUE (%)                       414 (16.6)            
  elix_BloodLoss = TRUE (%)                          44 ( 1.8)            
  elix_Anemia = TRUE (%)                            473 (18.9)            
  elix_Alcohol = TRUE (%)                            39 ( 1.6)            
  elix_Drugs = TRUE (%)                              35 ( 1.4)            
  elix_Psychoses = TRUE (%)                         214 ( 8.6)            
  elix_Depression = TRUE (%)                        437 (17.5)            
  lives_in_msa = TRUE (%)                             0 ( 0.0)            
  any_sx = TRUE (%)                                2131 (85.2)            
  motor = TRUE (%)                                 2023 (80.9)            
  bulbar = TRUE (%)                                 764 (30.6)            
  n_groups (%)                                                            
     0                                              369 (14.8)            
     1                                             1475 (59.0)            
     2                                              656 (26.2)            
  n_bulbar (%)                                                            
     0                                             1736 (69.4)            
     1                                              729 (29.2)            
     2                                               35 ( 1.4)            
  n_motor (%)                                                             
     0                                              477 (19.1)            
     1                                              572 (22.9)            
     2                                              452 (18.1)            
     3                                              522 (20.9)            
     4                                              332 (13.3)            
     5                                              121 ( 4.8)            
     6                                               24 ( 1.0)            
  n_total (%)                                                             
     0                                              369 (14.8)            
     1                                              509 (20.4)            
     2                                              486 (19.4)            
     3                                              486 (19.4)            
     4                                              381 (15.2)            
     5                                              177 ( 7.1)            
     6                                               74 ( 3.0)            
     7                                               18 ( 0.7)            
     8                                                0 ( 0.0)            
  speech = TRUE (%)                                 743 (29.7)            
  swallowing = TRUE (%)                              56 ( 2.2)            
  strength = TRUE (%)                               942 (37.7)            
  gait = TRUE (%)                                   725 (29.0)            
  involuntary_movement = TRUE (%)                   601 (24.0)            
  pain = TRUE (%)                                  1462 (58.5)            
  other = TRUE (%)                                 1244 (49.8)            
  falls = TRUE (%)                                  145 ( 5.8)            
                                               Stratified by als:lives_in_msa
                                                FALSE:TRUE                
  n                                               81245                   
  age (median [IQR])                              56.00 [47.00, 65.00]    
  female = TRUE (%)                               45689 ( 56.2)           
  first_year (median [IQR])                     2007.00 [2003.00, 2010.00]
  last_year (median [IQR])                      2012.00 [2008.00, 2015.00]
  rate_outpatient_visits (median [IQR])            7.16 [2.90, 14.69]     
  intensity_outpatient_visits_dx (median [IQR])    1.51 [1.21, 2.03]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.12]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 1.50]      
  elix_CHF = TRUE (%)                              7589 (  9.3)           
  elix_Valvular = TRUE (%)                        10971 ( 13.5)           
  elix_PHTN = TRUE (%)                             2668 (  3.3)           
  elix_PVD = TRUE (%)                             10365 ( 12.8)           
  elix_HTN = TRUE (%)                             40623 ( 50.0)           
  elix_HTNcx = TRUE (%)                            9632 ( 11.9)           
  elix_Paralysis = TRUE (%)                        1760 (  2.2)           
  elix_NeuroOther = TRUE (%)                       8512 ( 10.5)           
  elix_Pulmonary = TRUE (%)                       18375 ( 22.6)           
  elix_DM = TRUE (%)                              16976 ( 20.9)           
  elix_DMcx = TRUE (%)                             7288 (  9.0)           
  elix_Hypothyroid = TRUE (%)                     11556 ( 14.2)           
  elix_Renal = TRUE (%)                            5391 (  6.6)           
  elix_Liver = TRUE (%)                            4005 (  4.9)           
  elix_PUD = TRUE (%)                               426 (  0.5)           
  elix_HIV = TRUE (%)                               180 (  0.2)           
  elix_Lymphoma = TRUE (%)                         1163 (  1.4)           
  elix_Mets = TRUE (%)                             2974 (  3.7)           
  elix_Tumor = TRUE (%)                           10269 ( 12.6)           
  elix_Rheumatic = TRUE (%)                        4961 (  6.1)           
  elix_Coagulopathy = TRUE (%)                     3442 (  4.2)           
  elix_Obesity = TRUE (%)                          9450 ( 11.6)           
  elix_WeightLoss = TRUE (%)                       4556 (  5.6)           
  elix_FluidsLytes = TRUE (%)                     11410 ( 14.0)           
  elix_BloodLoss = TRUE (%)                        1729 (  2.1)           
  elix_Anemia = TRUE (%)                          14113 ( 17.4)           
  elix_Alcohol = TRUE (%)                          1742 (  2.1)           
  elix_Drugs = TRUE (%)                            1119 (  1.4)           
  elix_Psychoses = TRUE (%)                        6479 (  8.0)           
  elix_Depression = TRUE (%)                      10093 ( 12.4)           
  lives_in_msa = TRUE (%)                         81245 (100.0)           
  any_sx = TRUE (%)                               41332 ( 50.9)           
  motor = TRUE (%)                                39966 ( 49.2)           
  bulbar = TRUE (%)                                6581 (  8.1)           
  n_groups (%)                                                            
     0                                            39913 ( 49.1)           
     1                                            36117 ( 44.5)           
     2                                             5215 (  6.4)           
  n_bulbar (%)                                                            
     0                                            74664 ( 91.9)           
     1                                             6228 (  7.7)           
     2                                              353 (  0.4)           
  n_motor (%)                                                             
     0                                            41279 ( 50.8)           
     1                                            24844 ( 30.6)           
     2                                             7830 (  9.6)           
     3                                             4172 (  5.1)           
     4                                             2105 (  2.6)           
     5                                              842 (  1.0)           
     6                                              173 (  0.2)           
  n_total (%)                                                             
     0                                            39913 ( 49.1)           
     1                                            24070 ( 29.6)           
     2                                             8727 ( 10.7)           
     3                                             4531 (  5.6)           
     4                                             2241 (  2.8)           
     5                                             1167 (  1.4)           
     6                                              475 (  0.6)           
     7                                              112 (  0.1)           
     8                                                9 (  0.0)           
  speech = TRUE (%)                                5672 (  7.0)           
  swallowing = TRUE (%)                            1262 (  1.6)           
  strength = TRUE (%)                              4362 (  5.4)           
  gait = TRUE (%)                                  7294 (  9.0)           
  involuntary_movement = TRUE (%)                  5155 (  6.3)           
  pain = TRUE (%)                                 35538 ( 43.7)           
  other = TRUE (%)                                12157 ( 15.0)           
  falls = TRUE (%)                                 2182 (  2.7)           
                                               Stratified by als:lives_in_msa
                                                TRUE:TRUE                 
  n                                               16726                   
  age (median [IQR])                              56.00 [47.00, 65.00]    
  female = TRUE (%)                                9427 ( 56.4)           
  first_year (median [IQR])                     2007.00 [2003.00, 2010.00]
  last_year (median [IQR])                      2012.00 [2008.00, 2015.00]
  rate_outpatient_visits (median [IQR])           13.80 [7.35, 24.43]     
  intensity_outpatient_visits_dx (median [IQR])    1.60 [1.28, 2.12]      
  rate_inpatient_stays (median [IQR])              0.00 [0.00, 0.25]      
  intensity_inpatient_stays_los (median [IQR])     0.00 [0.00, 2.50]      
  elix_CHF = TRUE (%)                              1536 (  9.2)           
  elix_Valvular = TRUE (%)                         2761 ( 16.5)           
  elix_PHTN = TRUE (%)                              654 (  3.9)           
  elix_PVD = TRUE (%)                              2673 ( 16.0)           
  elix_HTN = TRUE (%)                              9138 ( 54.6)           
  elix_HTNcx = TRUE (%)                            2108 ( 12.6)           
  elix_Paralysis = TRUE (%)                        1953 ( 11.7)           
  elix_NeuroOther = TRUE (%)                       6823 ( 40.8)           
  elix_Pulmonary = TRUE (%)                        4586 ( 27.4)           
  elix_DM = TRUE (%)                               3486 ( 20.8)           
  elix_DMcx = TRUE (%)                             1476 (  8.8)           
  elix_Hypothyroid = TRUE (%)                      3138 ( 18.8)           
  elix_Renal = TRUE (%)                             933 (  5.6)           
  elix_Liver = TRUE (%)                             960 (  5.7)           
  elix_PUD = TRUE (%)                               111 (  0.7)           
  elix_HIV = TRUE (%)                                51 (  0.3)           
  elix_Lymphoma = TRUE (%)                          330 (  2.0)           
  elix_Mets = TRUE (%)                              349 (  2.1)           
  elix_Tumor = TRUE (%)                            2063 ( 12.3)           
  elix_Rheumatic = TRUE (%)                        1851 ( 11.1)           
  elix_Coagulopathy = TRUE (%)                      896 (  5.4)           
  elix_Obesity = TRUE (%)                          1936 ( 11.6)           
  elix_WeightLoss = TRUE (%)                       2022 ( 12.1)           
  elix_FluidsLytes = TRUE (%)                      2934 ( 17.5)           
  elix_BloodLoss = TRUE (%)                         353 (  2.1)           
  elix_Anemia = TRUE (%)                           3794 ( 22.7)           
  elix_Alcohol = TRUE (%)                           452 (  2.7)           
  elix_Drugs = TRUE (%)                             362 (  2.2)           
  elix_Psychoses = TRUE (%)                        2113 ( 12.6)           
  elix_Depression = TRUE (%)                       3180 ( 19.0)           
  lives_in_msa = TRUE (%)                         16726 (100.0)           
  any_sx = TRUE (%)                               13966 ( 83.5)           
  motor = TRUE (%)                                13185 ( 78.8)           
  bulbar = TRUE (%)                                4797 ( 28.7)           
  n_groups (%)                                                            
     0                                             2760 ( 16.5)           
     1                                             9950 ( 59.5)           
     2                                             4016 ( 24.0)           
  n_bulbar (%)                                                            
     0                                            11929 ( 71.3)           
     1                                             4465 ( 26.7)           
     2                                              332 (  2.0)           
  n_motor (%)                                                             
     0                                             3541 ( 21.2)           
     1                                             3955 ( 23.6)           
     2                                             2891 ( 17.3)           
     3                                             3050 ( 18.2)           
     4                                             2199 ( 13.1)           
     5                                              932 (  5.6)           
     6                                              158 (  0.9)           
  n_total (%)                                                             
     0                                             2760 ( 16.5)           
     1                                             3745 ( 22.4)           
     2                                             2995 ( 17.9)           
     3                                             2965 ( 17.7)           
     4                                             2282 ( 13.6)           
     5                                             1346 (  8.0)           
     6                                              504 (  3.0)           
     7                                              124 (  0.7)           
     8                                                5 (  0.0)           
  speech = TRUE (%)                                4613 ( 27.6)           
  swallowing = TRUE (%)                             516 (  3.1)           
  strength = TRUE (%)                              5807 ( 34.7)           
  gait = TRUE (%)                                  5036 ( 30.1)           
  involuntary_movement = TRUE (%)                  3960 ( 23.7)           
  pain = TRUE (%)                                  9685 ( 57.9)           
  other = TRUE (%)                                 7806 ( 46.7)           
  falls = TRUE (%)                                  997 (  6.0)           
                                               Stratified by als:lives_in_msa
                                                p      test    SMD   
  n                                                                  
  age (median [IQR])                            <0.001 nonnorm  0.035
  female = TRUE (%)                              0.001          0.022
  first_year (median [IQR])                      0.041 nonnorm  0.013
  last_year (median [IQR])                      <0.001 nonnorm  0.076
  rate_outpatient_visits (median [IQR])         <0.001 nonnorm  0.332
  intensity_outpatient_visits_dx (median [IQR]) <0.001 nonnorm  0.166
  rate_inpatient_stays (median [IQR])           <0.001 nonnorm  0.107
  intensity_inpatient_stays_los (median [IQR])  <0.001 nonnorm  0.089
  elix_CHF = TRUE (%)                            0.213          0.011
  elix_Valvular = TRUE (%)                      <0.001          0.079
  elix_PHTN = TRUE (%)                          <0.001          0.035
  elix_PVD = TRUE (%)                           <0.001          0.072
  elix_HTN = TRUE (%)                           <0.001          0.095
  elix_HTNcx = TRUE (%)                         <0.001          0.067
  elix_Paralysis = TRUE (%)                     <0.001          0.253
  elix_NeuroOther = TRUE (%)                    <0.001          0.507
  elix_Pulmonary = TRUE (%)                     <0.001          0.088
  elix_DM = TRUE (%)                             0.046          0.027
  elix_DMcx = TRUE (%)                          <0.001          0.054
  elix_Hypothyroid = TRUE (%)                   <0.001          0.084
  elix_Renal = TRUE (%)                         <0.001          0.041
  elix_Liver = TRUE (%)                         <0.001          0.037
  elix_PUD = TRUE (%)                            0.035          0.018
  elix_HIV = TRUE (%)                           <0.001          0.050
  elix_Lymphoma = TRUE (%)                      <0.001          0.039
  elix_Mets = TRUE (%)                          <0.001          0.085
  elix_Tumor = TRUE (%)                          0.001          0.038
  elix_Rheumatic = TRUE (%)                     <0.001          0.122
  elix_Coagulopathy = TRUE (%)                  <0.001          0.042
  elix_Obesity = TRUE (%)                        0.047          0.014
  elix_WeightLoss = TRUE (%)                    <0.001          0.167
  elix_FluidsLytes = TRUE (%)                   <0.001          0.071
  elix_BloodLoss = TRUE (%)                      0.114          0.016
  elix_Anemia = TRUE (%)                        <0.001          0.119
  elix_Alcohol = TRUE (%)                       <0.001          0.043
  elix_Drugs = TRUE (%)                         <0.001          0.040
  elix_Psychoses = TRUE (%)                     <0.001          0.111
  elix_Depression = TRUE (%)                    <0.001          0.123
  lives_in_msa = TRUE (%)                       <0.001            NaN
  any_sx = TRUE (%)                             <0.001          0.533
  motor = TRUE (%)                              <0.001          0.475
  bulbar = TRUE (%)                             <0.001          0.401
  n_groups (%)                                  <0.001          0.596
     0                                                               
     1                                                               
     2                                                               
  n_bulbar (%)                                  <0.001          0.406
     0                                                               
     1                                                               
     2                                                               
  n_motor (%)                                   <0.001          0.662
     0                                                               
     1                                                               
     2                                                               
     3                                                               
     4                                                               
     5                                                               
     6                                                               
  n_total (%)                                   <0.001          0.735
     0                                                               
     1                                                               
     2                                                               
     3                                                               
     4                                                               
     5                                                               
     6                                                               
     7                                                               
     8                                                               
  speech = TRUE (%)                             <0.001          0.413
  swallowing = TRUE (%)                         <0.001          0.067
  strength = TRUE (%)                           <0.001          0.577
  gait = TRUE (%)                               <0.001          0.395
  involuntary_movement = TRUE (%)               <0.001          0.340
  pain = TRUE (%)                               <0.001          0.210
  other = TRUE (%)                              <0.001          0.540
  falls = TRUE (%)                              <0.001          0.110

Define Models

I want to fit XXXX models:

First, does having any of these codes increase the odds of getting an ALS diagnosis?

any_fml_unadj <- als ~ any_sx * lives_in_msa + strata(stratum)

any_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   any_sx * lives_in_msa + strata(stratum)

Second, what is the independent effect of bulbar symptoms?

any_bulbar_unadj <- als ~ bulbar * lives_in_msa + strata(stratum)

any_bulbar_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   bulbar * lives_in_msa + strata(stratum)

Third, what is the independent effect of motor symptoms?

any_motor_unadj <- als ~ motor * lives_in_msa + strata(stratum)

any_motor_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   motor * lives_in_msa + strata(stratum)

Fourth, what is the effect of symptoms from 0, 1, or 2 affects systems?

number_origin_unadj <- als ~ as.factor(I(bulbar + motor)) * lives_in_msa + strata(stratum)

number_origin_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   as.factor(I(bulbar + motor)) * lives_in_msa + strata(stratum)

Fifth, what is the effect of the symptom sub-class? This is actually many models…

speech_fml_unadj <- als ~ speech * lives_in_msa + strata(stratum)

speech_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   speech * lives_in_msa + strata(stratum)

swallowing_fml_unadj <- als ~ swallowing * lives_in_msa + strata(stratum)

swallowing_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   swallowing * lives_in_msa + strata(stratum)

strength_fml_unadj <- als ~ strength * lives_in_msa + strata(stratum)

strength_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   strength * lives_in_msa + strata(stratum)

gait_fml_unadj <- als ~ gait * lives_in_msa + strata(stratum)

gait_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   gait * lives_in_msa + strata(stratum)

involuntary_movement_fml_unadj <- als ~ involuntary_movement * lives_in_msa + strata(stratum)

involuntary_movement_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   involuntary_movement * lives_in_msa + strata(stratum)

pain_fml_unadj <- als ~ pain * lives_in_msa + strata(stratum)

pain_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   pain * lives_in_msa + strata(stratum)

other_fml_unadj <- als ~ other * lives_in_msa + strata(stratum)

other_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   other * lives_in_msa + strata(stratum)

falls_fml_unadj <- als ~ falls * lives_in_msa + strata(stratum)

falls_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   falls * lives_in_msa + strata(stratum)

Sixth, does the risk increase with each additional symptom?

number_fml_unadj <- als ~ as.factor(n_total) * lives_in_msa + strata(stratum)

number_fml_fulladj <- als ~ rate_outpatient_visits + intensity_outpatient_visits_dx + 
                   rate_inpatient_stays + intensity_inpatient_stays_los +
                   elix_CHF + elix_Valvular + elix_PHTN + elix_PVD + elix_HTN +
                   elix_HTNcx + elix_Paralysis + elix_NeuroOther + elix_Pulmonary + elix_DM +
                   elix_DMcx + elix_Hypothyroid + elix_Renal + elix_Liver + elix_PUD + 
                   elix_HIV + elix_Lymphoma + elix_Mets + elix_Tumor + elix_Rheumatic + 
                   elix_Coagulopathy + elix_Obesity + elix_WeightLoss + elix_FluidsLytes + elix_BloodLoss + 
                   elix_Anemia + elix_Alcohol + elix_Drugs + elix_Psychoses + elix_Depression + 
                   as.factor(n_total) * lives_in_msa + strata(stratum)

Quick note: all of these models omit year, age, and sex. This is because the data are matched on age, sex, and enrollment start/end dates. Including the strata accounts for these factors while also properly clustering the errors.

Estimation

Does Having Any Code Increase the Risk?

Without adjustment:

clogit(
  any_fml_unadj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
any_sxTRUE 7.44 6.62 8.36
lives_in_msaTRUE 1.43 1.28 1.60
any_sxTRUE:lives_in_msaTRUE 0.84 0.75 0.96

The odds are increased following one or more symptom (OR = 7.44), for those living in MSAs (OR = 1.43), but there is a multiplicative decrease in odds for ALS for those with symptoms living in an MSA (OR = 0.84). The odds are still increased (OR = \(0.84 * 7.44 = 6.25\)) but less than for those who do not live in MSAs.

After adjustment, the story stays the same:

clogit(
  any_fml_fulladj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.02 1.02 1.03
intensity_outpatient_visits_dx 1.15 1.10 1.19
rate_inpatient_stays 0.78 0.74 0.82
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.64 0.59 0.69
elix_ValvularTRUE 0.97 0.92 1.03
elix_PHTNTRUE 0.99 0.90 1.09
elix_PVDTRUE 0.91 0.86 0.96
elix_HTNTRUE 0.98 0.94 1.02
elix_HTNcxTRUE 0.91 0.85 0.97
elix_ParalysisTRUE 3.00 2.78 3.23
elix_NeuroOtherTRUE 5.21 4.98 5.45
elix_PulmonaryTRUE 0.95 0.91 1.00
elix_DMTRUE 0.86 0.82 0.91
elix_DMcxTRUE 0.80 0.74 0.86
elix_HypothyroidTRUE 1.11 1.05 1.16
elix_RenalTRUE 0.60 0.55 0.65
elix_LiverTRUE 0.94 0.87 1.02
elix_PUDTRUE 1.00 0.80 1.25
elix_HIVTRUE 0.98 0.68 1.40
elix_LymphomaTRUE 1.20 1.05 1.38
elix_MetsTRUE 0.33 0.29 0.38
elix_TumorTRUE 0.86 0.81 0.92
elix_RheumaticTRUE 1.24 1.17 1.32
elix_CoagulopathyTRUE 0.85 0.78 0.93
elix_ObesityTRUE 0.83 0.78 0.88
elix_WeightLossTRUE 1.69 1.59 1.81
elix_FluidsLytesTRUE 0.80 0.75 0.85
elix_BloodLossTRUE 0.70 0.61 0.79
elix_AnemiaTRUE 1.05 0.99 1.10
elix_AlcoholTRUE 0.83 0.74 0.93
elix_DrugsTRUE 0.82 0.72 0.94
elix_PsychosesTRUE 0.82 0.77 0.87
elix_DepressionTRUE 0.97 0.92 1.02
any_sxTRUE 4.92 4.36 5.56
lives_in_msaTRUE 1.44 1.28 1.61
any_sxTRUE:lives_in_msaTRUE 0.83 0.73 0.94

Are There Differences Between Bulbar and Motor Symptoms?

Bulbar symptoms alone increases the odds before adjustment:

clogit(
  any_bulbar_unadj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
bulbarTRUE 6.39 5.74 7.11
lives_in_msaTRUE 1.30 1.23 1.37
bulbarTRUE:lives_in_msaTRUE 0.84 0.75 0.94

And unsurprisingly adjustment does not change the story:

clogit(
  any_bulbar_fulladj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.29 1.25 1.34
rate_inpatient_stays 0.78 0.74 0.83
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.60 0.55 0.65
elix_ValvularTRUE 0.94 0.89 1.00
elix_PHTNTRUE 0.94 0.85 1.04
elix_PVDTRUE 0.92 0.87 0.98
elix_HTNTRUE 1.03 0.99 1.08
elix_HTNcxTRUE 0.88 0.82 0.94
elix_ParalysisTRUE 3.00 2.77 3.24
elix_NeuroOtherTRUE 5.23 4.99 5.47
elix_PulmonaryTRUE 0.93 0.89 0.97
elix_DMTRUE 0.85 0.80 0.90
elix_DMcxTRUE 0.80 0.74 0.87
elix_HypothyroidTRUE 1.10 1.04 1.15
elix_RenalTRUE 0.55 0.50 0.60
elix_LiverTRUE 0.95 0.88 1.03
elix_PUDTRUE 0.92 0.72 1.16
elix_HIVTRUE 0.85 0.59 1.22
elix_LymphomaTRUE 1.15 1.00 1.32
elix_MetsTRUE 0.30 0.26 0.34
elix_TumorTRUE 0.84 0.79 0.89
elix_RheumaticTRUE 1.36 1.27 1.45
elix_CoagulopathyTRUE 0.83 0.76 0.91
elix_ObesityTRUE 0.84 0.79 0.90
elix_WeightLossTRUE 1.57 1.47 1.67
elix_FluidsLytesTRUE 0.77 0.73 0.82
elix_BloodLossTRUE 0.65 0.57 0.74
elix_AnemiaTRUE 1.05 1.00 1.11
elix_AlcoholTRUE 0.88 0.78 0.99
elix_DrugsTRUE 0.83 0.72 0.96
elix_PsychosesTRUE 0.79 0.74 0.84
elix_DepressionTRUE 0.96 0.91 1.02
bulbarTRUE 3.80 3.37 4.29
lives_in_msaTRUE 1.27 1.20 1.35
bulbarTRUE:lives_in_msaTRUE 0.84 0.74 0.95

The same is true of motor symptoms

clogit(
  any_motor_unadj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
motorTRUE 5.64 5.07 6.27
lives_in_msaTRUE 1.42 1.29 1.57
motorTRUE:lives_in_msaTRUE 0.84 0.75 0.94

and with adjustment:

clogit(
  any_motor_fulladj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.02 1.03
intensity_outpatient_visits_dx 1.19 1.15 1.23
rate_inpatient_stays 0.78 0.74 0.82
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.63 0.58 0.68
elix_ValvularTRUE 0.97 0.92 1.02
elix_PHTNTRUE 0.98 0.89 1.08
elix_PVDTRUE 0.91 0.86 0.96
elix_HTNTRUE 0.98 0.94 1.02
elix_HTNcxTRUE 0.91 0.85 0.96
elix_ParalysisTRUE 3.03 2.81 3.27
elix_NeuroOtherTRUE 5.42 5.18 5.67
elix_PulmonaryTRUE 0.97 0.93 1.01
elix_DMTRUE 0.86 0.81 0.90
elix_DMcxTRUE 0.79 0.73 0.85
elix_HypothyroidTRUE 1.12 1.06 1.17
elix_RenalTRUE 0.59 0.54 0.64
elix_LiverTRUE 0.94 0.87 1.02
elix_PUDTRUE 1.02 0.82 1.28
elix_HIVTRUE 0.99 0.69 1.41
elix_LymphomaTRUE 1.19 1.04 1.36
elix_MetsTRUE 0.33 0.29 0.37
elix_TumorTRUE 0.86 0.81 0.91
elix_RheumaticTRUE 1.25 1.17 1.33
elix_CoagulopathyTRUE 0.84 0.77 0.92
elix_ObesityTRUE 0.83 0.78 0.88
elix_WeightLossTRUE 1.73 1.62 1.84
elix_FluidsLytesTRUE 0.80 0.75 0.84
elix_BloodLossTRUE 0.69 0.61 0.79
elix_AnemiaTRUE 1.04 0.99 1.09
elix_AlcoholTRUE 0.83 0.74 0.94
elix_DrugsTRUE 0.81 0.71 0.93
elix_PsychosesTRUE 0.81 0.76 0.86
elix_DepressionTRUE 0.97 0.92 1.02
motorTRUE 3.75 3.35 4.19
lives_in_msaTRUE 1.43 1.29 1.58
motorTRUE:lives_in_msaTRUE 0.82 0.73 0.92

Does the Risk Increase With Symptoms From Different Origins?

Without adjustment:

clogit(
  number_origin_unadj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
as.factor(I(bulbar + motor))1 5.98 5.30 6.74
as.factor(I(bulbar + motor))2 26.38 22.68 30.67
lives_in_msaTRUE 1.45 1.30 1.62
as.factor(I(bulbar + motor))1:lives_in_msaTRUE 0.88 0.78 1.00
as.factor(I(bulbar + motor))2:lives_in_msaTRUE 0.71 0.61 0.84

And with adjustment

clogit(
  number_origin_fulladj,
  model_data
) |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.02 1.02 1.02
intensity_outpatient_visits_dx 1.13 1.09 1.17
rate_inpatient_stays 0.79 0.74 0.84
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.63 0.59 0.68
elix_ValvularTRUE 0.95 0.90 1.01
elix_PHTNTRUE 0.98 0.88 1.08
elix_PVDTRUE 0.89 0.84 0.95
elix_HTNTRUE 0.98 0.94 1.02
elix_HTNcxTRUE 0.90 0.84 0.96
elix_ParalysisTRUE 2.77 2.56 2.99
elix_NeuroOtherTRUE 4.75 4.54 4.97
elix_PulmonaryTRUE 0.92 0.88 0.96
elix_DMTRUE 0.86 0.81 0.91
elix_DMcxTRUE 0.80 0.74 0.87
elix_HypothyroidTRUE 1.09 1.04 1.14
elix_RenalTRUE 0.60 0.55 0.66
elix_LiverTRUE 0.94 0.87 1.02
elix_PUDTRUE 0.95 0.75 1.20
elix_HIVTRUE 1.02 0.70 1.46
elix_LymphomaTRUE 1.19 1.04 1.37
elix_MetsTRUE 0.33 0.29 0.38
elix_TumorTRUE 0.86 0.80 0.91
elix_RheumaticTRUE 1.22 1.15 1.30
elix_CoagulopathyTRUE 0.85 0.78 0.93
elix_ObesityTRUE 0.81 0.76 0.86
elix_WeightLossTRUE 1.57 1.47 1.68
elix_FluidsLytesTRUE 0.78 0.74 0.83
elix_BloodLossTRUE 0.68 0.60 0.78
elix_AnemiaTRUE 1.05 0.99 1.10
elix_AlcoholTRUE 0.85 0.75 0.96
elix_DrugsTRUE 0.84 0.73 0.97
elix_PsychosesTRUE 0.81 0.76 0.86
elix_DepressionTRUE 0.94 0.89 0.99
as.factor(I(bulbar + motor))1 4.37 3.85 4.95
as.factor(I(bulbar + motor))2 13.11 11.14 15.43
lives_in_msaTRUE 1.44 1.29 1.62
as.factor(I(bulbar + motor))1:lives_in_msaTRUE 0.87 0.76 0.99
as.factor(I(bulbar + motor))2:lives_in_msaTRUE 0.70 0.59 0.83

By Symptom

Bulbar Symptoms

Speech Problems

speech_unadjusted <- clogit(
  speech_fml_unadj,
  model_data
)

speech_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
speechTRUE 7.33 6.57 8.19
lives_in_msaTRUE 1.30 1.23 1.37
speechTRUE:lives_in_msaTRUE 0.83 0.74 0.93
speech_adjusted <- clogit(
  speech_fml_fulladj,
  model_data
)

speech_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.29 1.25 1.34
rate_inpatient_stays 0.78 0.73 0.83
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.59 0.55 0.64
elix_ValvularTRUE 0.94 0.89 1.00
elix_PHTNTRUE 0.93 0.84 1.03
elix_PVDTRUE 0.92 0.87 0.98
elix_HTNTRUE 1.04 0.99 1.08
elix_HTNcxTRUE 0.88 0.83 0.94
elix_ParalysisTRUE 2.96 2.74 3.20
elix_NeuroOtherTRUE 5.15 4.92 5.39
elix_PulmonaryTRUE 0.93 0.89 0.97
elix_DMTRUE 0.85 0.80 0.90
elix_DMcxTRUE 0.80 0.74 0.87
elix_HypothyroidTRUE 1.10 1.05 1.16
elix_RenalTRUE 0.55 0.50 0.60
elix_LiverTRUE 0.95 0.88 1.03
elix_PUDTRUE 0.90 0.71 1.14
elix_HIVTRUE 0.87 0.60 1.24
elix_LymphomaTRUE 1.16 1.01 1.33
elix_MetsTRUE 0.30 0.26 0.34
elix_TumorTRUE 0.84 0.79 0.89
elix_RheumaticTRUE 1.36 1.28 1.45
elix_CoagulopathyTRUE 0.83 0.76 0.91
elix_ObesityTRUE 0.85 0.80 0.90
elix_WeightLossTRUE 1.55 1.45 1.66
elix_FluidsLytesTRUE 0.77 0.73 0.82
elix_BloodLossTRUE 0.65 0.57 0.74
elix_AnemiaTRUE 1.05 1.00 1.11
elix_AlcoholTRUE 0.87 0.77 0.98
elix_DrugsTRUE 0.83 0.72 0.96
elix_PsychosesTRUE 0.79 0.74 0.84
elix_DepressionTRUE 0.96 0.91 1.02
speechTRUE 4.28 3.78 4.85
lives_in_msaTRUE 1.27 1.20 1.35
speechTRUE:lives_in_msaTRUE 0.83 0.72 0.94

Swallowing Problems

swallowing_unadjusted <- clogit(
  swallowing_fml_unadj,
  model_data
)

swallowing_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
swallowingTRUE 1.68 1.24 2.26
lives_in_msaTRUE 1.23 1.17 1.28
swallowingTRUE:lives_in_msaTRUE 1.22 0.89 1.67
swallowing_adjusted <- clogit(
  swallowing_fml_fulladj,
  model_data
)

swallowing_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.04
intensity_outpatient_visits_dx 1.33 1.29 1.37
rate_inpatient_stays 0.77 0.73 0.82
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.60 0.56 0.65
elix_ValvularTRUE 0.96 0.91 1.02
elix_PHTNTRUE 0.95 0.86 1.05
elix_PVDTRUE 0.94 0.88 0.99
elix_HTNTRUE 1.03 0.99 1.07
elix_HTNcxTRUE 0.89 0.84 0.95
elix_ParalysisTRUE 3.30 3.06 3.56
elix_NeuroOtherTRUE 5.99 5.73 6.26
elix_PulmonaryTRUE 0.98 0.94 1.03
elix_DMTRUE 0.85 0.80 0.90
elix_DMcxTRUE 0.78 0.73 0.85
elix_HypothyroidTRUE 1.13 1.07 1.18
elix_RenalTRUE 0.54 0.50 0.59
elix_LiverTRUE 0.95 0.88 1.03
elix_PUDTRUE 1.01 0.80 1.26
elix_HIVTRUE 0.85 0.59 1.21
elix_LymphomaTRUE 1.16 1.01 1.33
elix_MetsTRUE 0.30 0.27 0.34
elix_TumorTRUE 0.84 0.80 0.90
elix_RheumaticTRUE 1.37 1.29 1.46
elix_CoagulopathyTRUE 0.83 0.76 0.91
elix_ObesityTRUE 0.86 0.81 0.91
elix_WeightLossTRUE 1.75 1.64 1.86
elix_FluidsLytesTRUE 0.80 0.75 0.84
elix_BloodLossTRUE 0.67 0.58 0.76
elix_AnemiaTRUE 1.05 1.00 1.10
elix_AlcoholTRUE 0.86 0.76 0.97
elix_DrugsTRUE 0.80 0.70 0.92
elix_PsychosesTRUE 0.80 0.75 0.85
elix_DepressionTRUE 1.00 0.95 1.05
swallowingTRUE 1.23 0.87 1.73
lives_in_msaTRUE 1.21 1.15 1.28
swallowingTRUE:lives_in_msaTRUE 1.20 0.84 1.72

Motor Problems

Strength Problems

strength_unadjusted <- clogit(
  strength_fml_unadj,
  model_data
)

strength_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
strengthTRUE 16.13 14.34 18.14
lives_in_msaTRUE 1.33 1.25 1.40
strengthTRUE:lives_in_msaTRUE 0.74 0.66 0.84
strength_adjusted <- clogit(
  strength_fml_fulladj,
  model_data
)

strength_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.22 1.17 1.26
rate_inpatient_stays 0.77 0.72 0.81
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.57 0.53 0.62
elix_ValvularTRUE 0.98 0.92 1.03
elix_PHTNTRUE 0.91 0.82 1.02
elix_PVDTRUE 0.88 0.82 0.93
elix_HTNTRUE 1.05 1.00 1.09
elix_HTNcxTRUE 0.91 0.85 0.97
elix_ParalysisTRUE 2.33 2.14 2.53
elix_NeuroOtherTRUE 5.05 4.82 5.30
elix_PulmonaryTRUE 1.00 0.96 1.05
elix_DMTRUE 0.87 0.82 0.92
elix_DMcxTRUE 0.75 0.69 0.81
elix_HypothyroidTRUE 1.14 1.08 1.20
elix_RenalTRUE 0.52 0.47 0.57
elix_LiverTRUE 0.97 0.89 1.05
elix_PUDTRUE 1.06 0.83 1.36
elix_HIVTRUE 0.94 0.64 1.38
elix_LymphomaTRUE 1.17 1.01 1.35
elix_MetsTRUE 0.30 0.26 0.35
elix_TumorTRUE 0.86 0.80 0.91
elix_RheumaticTRUE 1.28 1.19 1.36
elix_CoagulopathyTRUE 0.80 0.73 0.88
elix_ObesityTRUE 0.83 0.78 0.89
elix_WeightLossTRUE 1.61 1.51 1.73
elix_FluidsLytesTRUE 0.75 0.70 0.80
elix_BloodLossTRUE 0.61 0.53 0.70
elix_AnemiaTRUE 1.03 0.98 1.09
elix_AlcoholTRUE 0.88 0.77 1.00
elix_DrugsTRUE 0.83 0.72 0.97
elix_PsychosesTRUE 0.81 0.76 0.87
elix_DepressionTRUE 0.95 0.90 1.01
strengthTRUE 10.47 9.18 11.93
lives_in_msaTRUE 1.31 1.24 1.39
strengthTRUE:lives_in_msaTRUE 0.74 0.64 0.85

Gait Problems

gait_unadjusted <- clogit(
  gait_fml_unadj,
  model_data
)

gait_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
gaitTRUE 6.37 5.71 7.11
lives_in_msaTRUE 1.25 1.18 1.32
gaitTRUE:lives_in_msaTRUE 0.86 0.77 0.97
gait_adjusted <- clogit(
  gait_fml_fulladj,
  model_data
)

gait_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.29 1.25 1.34
rate_inpatient_stays 0.74 0.70 0.79
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.59 0.55 0.64
elix_ValvularTRUE 0.97 0.92 1.03
elix_PHTNTRUE 0.92 0.83 1.02
elix_PVDTRUE 0.89 0.84 0.94
elix_HTNTRUE 1.02 0.98 1.07
elix_HTNcxTRUE 0.88 0.83 0.94
elix_ParalysisTRUE 2.69 2.48 2.91
elix_NeuroOtherTRUE 5.20 4.97 5.44
elix_PulmonaryTRUE 1.00 0.96 1.05
elix_DMTRUE 0.86 0.82 0.91
elix_DMcxTRUE 0.76 0.71 0.83
elix_HypothyroidTRUE 1.14 1.08 1.20
elix_RenalTRUE 0.55 0.50 0.60
elix_LiverTRUE 0.97 0.90 1.05
elix_PUDTRUE 1.06 0.84 1.33
elix_HIVTRUE 0.87 0.61 1.25
elix_LymphomaTRUE 1.18 1.03 1.36
elix_MetsTRUE 0.30 0.27 0.35
elix_TumorTRUE 0.85 0.80 0.91
elix_RheumaticTRUE 1.32 1.24 1.41
elix_CoagulopathyTRUE 0.82 0.75 0.89
elix_ObesityTRUE 0.83 0.78 0.88
elix_WeightLossTRUE 1.72 1.61 1.84
elix_FluidsLytesTRUE 0.77 0.72 0.81
elix_BloodLossTRUE 0.65 0.57 0.75
elix_AnemiaTRUE 1.03 0.97 1.08
elix_AlcoholTRUE 0.85 0.76 0.96
elix_DrugsTRUE 0.80 0.70 0.93
elix_PsychosesTRUE 0.77 0.72 0.82
elix_DepressionTRUE 0.98 0.92 1.03
gaitTRUE 3.22 2.84 3.65
lives_in_msaTRUE 1.24 1.17 1.31
gaitTRUE:lives_in_msaTRUE 0.90 0.79 1.02

Involuntary Movements

involuntary_movements_unadjusted <- clogit(
  involuntary_movement_fml_unadj,
  model_data
)

involuntary_movements_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
involuntary_movementTRUE 5.06 4.51 5.67
lives_in_msaTRUE 1.26 1.19 1.32
involuntary_movementTRUE:lives_in_msaTRUE 0.97 0.85 1.09
involuntary_movements_adjusted <- clogit(
  involuntary_movement_fml_fulladj,
  model_data
)

involuntary_movements_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.28 1.23 1.32
rate_inpatient_stays 0.79 0.75 0.84
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.61 0.57 0.66
elix_ValvularTRUE 0.97 0.91 1.02
elix_PHTNTRUE 0.96 0.87 1.06
elix_PVDTRUE 0.94 0.88 0.99
elix_HTNTRUE 1.02 0.98 1.07
elix_HTNcxTRUE 0.89 0.84 0.95
elix_ParalysisTRUE 3.11 2.87 3.36
elix_NeuroOtherTRUE 5.57 5.33 5.83
elix_PulmonaryTRUE 0.97 0.93 1.02
elix_DMTRUE 0.86 0.82 0.91
elix_DMcxTRUE 0.80 0.74 0.86
elix_HypothyroidTRUE 1.12 1.07 1.18
elix_RenalTRUE 0.55 0.50 0.60
elix_LiverTRUE 0.93 0.86 1.01
elix_PUDTRUE 0.95 0.75 1.20
elix_HIVTRUE 0.94 0.66 1.34
elix_LymphomaTRUE 1.19 1.03 1.36
elix_MetsTRUE 0.31 0.27 0.35
elix_TumorTRUE 0.86 0.80 0.91
elix_RheumaticTRUE 1.30 1.22 1.39
elix_CoagulopathyTRUE 0.84 0.77 0.92
elix_ObesityTRUE 0.86 0.81 0.91
elix_WeightLossTRUE 1.72 1.61 1.84
elix_FluidsLytesTRUE 0.79 0.74 0.84
elix_BloodLossTRUE 0.67 0.59 0.76
elix_AnemiaTRUE 1.05 1.00 1.10
elix_AlcoholTRUE 0.85 0.76 0.96
elix_DrugsTRUE 0.74 0.64 0.86
elix_PsychosesTRUE 0.78 0.73 0.84
elix_DepressionTRUE 0.97 0.92 1.02
involuntary_movementTRUE 3.23 2.83 3.68
lives_in_msaTRUE 1.24 1.17 1.31
involuntary_movementTRUE:lives_in_msaTRUE 0.96 0.83 1.10

Pain

pain_unadjusted <- clogit(
  pain_fml_unadj,
  model_data
)

pain_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
painTRUE 2.11 1.94 2.30
lives_in_msaTRUE 1.29 1.20 1.38
painTRUE:lives_in_msaTRUE 0.93 0.85 1.02
pain_adjusted <- clogit(
  pain_fml_fulladj,
  model_data
)

pain_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.03
intensity_outpatient_visits_dx 1.30 1.26 1.35
rate_inpatient_stays 0.77 0.73 0.82
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.61 0.56 0.65
elix_ValvularTRUE 0.96 0.91 1.02
elix_PHTNTRUE 0.95 0.86 1.05
elix_PVDTRUE 0.92 0.87 0.98
elix_HTNTRUE 1.02 0.98 1.06
elix_HTNcxTRUE 0.89 0.84 0.95
elix_ParalysisTRUE 3.27 3.03 3.53
elix_NeuroOtherTRUE 5.97 5.71 6.24
elix_PulmonaryTRUE 0.98 0.93 1.02
elix_DMTRUE 0.85 0.80 0.90
elix_DMcxTRUE 0.78 0.72 0.84
elix_HypothyroidTRUE 1.12 1.07 1.18
elix_RenalTRUE 0.55 0.50 0.60
elix_LiverTRUE 0.95 0.88 1.03
elix_PUDTRUE 1.01 0.80 1.27
elix_HIVTRUE 0.89 0.62 1.27
elix_LymphomaTRUE 1.16 1.02 1.34
elix_MetsTRUE 0.31 0.27 0.35
elix_TumorTRUE 0.85 0.80 0.90
elix_RheumaticTRUE 1.32 1.24 1.41
elix_CoagulopathyTRUE 0.83 0.76 0.91
elix_ObesityTRUE 0.85 0.80 0.90
elix_WeightLossTRUE 1.76 1.65 1.87
elix_FluidsLytesTRUE 0.80 0.75 0.84
elix_BloodLossTRUE 0.67 0.59 0.76
elix_AnemiaTRUE 1.04 0.99 1.10
elix_AlcoholTRUE 0.85 0.76 0.96
elix_DrugsTRUE 0.80 0.69 0.91
elix_PsychosesTRUE 0.80 0.75 0.85
elix_DepressionTRUE 0.99 0.94 1.04
painTRUE 1.47 1.33 1.62
lives_in_msaTRUE 1.29 1.20 1.39
painTRUE:lives_in_msaTRUE 0.91 0.82 1.00

Falls

falls_unadjusted <- clogit(
  falls_fml_unadj,
  model_data
)

falls_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
fallsTRUE 2.46 2.02 2.99
lives_in_msaTRUE 1.24 1.18 1.29
fallsTRUE:lives_in_msaTRUE 1.02 0.83 1.26
falls_adjusted <- clogit(
  falls_fml_fulladj,
  model_data
)

falls_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.03 1.04
intensity_outpatient_visits_dx 1.33 1.28 1.37
rate_inpatient_stays 0.77 0.73 0.81
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.60 0.56 0.65
elix_ValvularTRUE 0.97 0.91 1.02
elix_PHTNTRUE 0.95 0.86 1.05
elix_PVDTRUE 0.94 0.88 0.99
elix_HTNTRUE 1.03 0.99 1.07
elix_HTNcxTRUE 0.89 0.84 0.95
elix_ParalysisTRUE 3.26 3.03 3.52
elix_NeuroOtherTRUE 5.96 5.70 6.23
elix_PulmonaryTRUE 0.98 0.94 1.03
elix_DMTRUE 0.85 0.81 0.90
elix_DMcxTRUE 0.78 0.72 0.84
elix_HypothyroidTRUE 1.13 1.08 1.19
elix_RenalTRUE 0.54 0.50 0.59
elix_LiverTRUE 0.95 0.88 1.03
elix_PUDTRUE 1.01 0.81 1.27
elix_HIVTRUE 0.85 0.60 1.22
elix_LymphomaTRUE 1.16 1.01 1.33
elix_MetsTRUE 0.30 0.27 0.34
elix_TumorTRUE 0.85 0.80 0.90
elix_RheumaticTRUE 1.37 1.29 1.46
elix_CoagulopathyTRUE 0.83 0.76 0.90
elix_ObesityTRUE 0.86 0.81 0.91
elix_WeightLossTRUE 1.75 1.64 1.87
elix_FluidsLytesTRUE 0.79 0.75 0.84
elix_BloodLossTRUE 0.67 0.58 0.76
elix_AnemiaTRUE 1.05 1.00 1.10
elix_AlcoholTRUE 0.85 0.76 0.96
elix_DrugsTRUE 0.80 0.69 0.92
elix_PsychosesTRUE 0.79 0.75 0.85
elix_DepressionTRUE 0.99 0.94 1.05
fallsTRUE 1.20 0.95 1.51
lives_in_msaTRUE 1.22 1.16 1.28
fallsTRUE:lives_in_msaTRUE 1.04 0.81 1.33

Other

other_unadjusted <- clogit(
  other_fml_unadj,
  model_data
)

other_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
otherTRUE 7.13 6.50 7.83
lives_in_msaTRUE 1.35 1.27 1.44
otherTRUE:lives_in_msaTRUE 0.81 0.74 0.90
other_adjusted <- clogit(
  other_fml_fulladj,
  model_data
) 

other_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.03 1.02 1.03
intensity_outpatient_visits_dx 1.23 1.19 1.27
rate_inpatient_stays 0.80 0.76 0.85
intensity_inpatient_stays_los 1.00 0.99 1.00
elix_CHFTRUE 0.61 0.57 0.66
elix_ValvularTRUE 0.96 0.91 1.02
elix_PHTNTRUE 0.96 0.86 1.06
elix_PVDTRUE 0.90 0.85 0.96
elix_HTNTRUE 1.03 0.99 1.07
elix_HTNcxTRUE 0.90 0.84 0.96
elix_ParalysisTRUE 2.68 2.47 2.90
elix_NeuroOtherTRUE 5.36 5.12 5.61
elix_PulmonaryTRUE 0.98 0.94 1.03
elix_DMTRUE 0.86 0.82 0.91
elix_DMcxTRUE 0.77 0.71 0.83
elix_HypothyroidTRUE 1.11 1.06 1.17
elix_RenalTRUE 0.56 0.51 0.61
elix_LiverTRUE 0.94 0.87 1.02
elix_PUDTRUE 0.99 0.78 1.25
elix_HIVTRUE 0.93 0.64 1.35
elix_LymphomaTRUE 1.21 1.05 1.40
elix_MetsTRUE 0.33 0.29 0.38
elix_TumorTRUE 0.86 0.81 0.92
elix_RheumaticTRUE 1.24 1.16 1.32
elix_CoagulopathyTRUE 0.83 0.76 0.91
elix_ObesityTRUE 0.82 0.77 0.87
elix_WeightLossTRUE 1.69 1.59 1.81
elix_FluidsLytesTRUE 0.77 0.72 0.81
elix_BloodLossTRUE 0.65 0.57 0.75
elix_AnemiaTRUE 1.04 0.99 1.10
elix_AlcoholTRUE 0.89 0.78 1.00
elix_DrugsTRUE 0.78 0.67 0.90
elix_PsychosesTRUE 0.81 0.76 0.87
elix_DepressionTRUE 0.97 0.91 1.02
otherTRUE 4.77 4.31 5.28
lives_in_msaTRUE 1.34 1.26 1.43
otherTRUE:lives_in_msaTRUE 0.81 0.73 0.90

To summarize these in a practical way:

list(
  speech_unadjusted,
  swallowing_unadjusted,
  strength_unadjusted,
  gait_unadjusted,
  involuntary_movements_unadjusted,
  pain_unadjusted,
  falls_unadjusted,
  other_unadjusted
) |>
  lapply(
    broom::tidy,
    exponentiate = TRUE,
    conf.int = TRUE
  ) |>
  enframe() |>
  mutate(
    symptom = c("Speech", "Swallowing", "Muscle",
                "Gait", "Involuntary\nMovements", "Pain", "Falls",
                "Other Motor")
  ) |>
  unnest(cols = value) |>
  mutate(
    variable = rep(c("Symptom", "Lives in Urban Area", "Symptom x Lives in Urban Area"), 8)
  ) |>
  mutate(
    symptom = forcats::fct_relevel(
      symptom,
      "Speech", "Swallowing", "Muscle",
      "Gait", "Involuntary\nMovements", "Pain", "Falls",
      "Other Motor"
    ),
    variable = forcats::fct_relevel(
      variable,
      "Symptom", "Lives in Urban Area", "Symptom x Lives in Urban Area"
    )
  ) |>
  ggplot(
    aes(
      x = symptom,
      y = estimate,
      ymin = conf.low,
      ymax = conf.high
    )
  ) + 
  geom_point() +
  geom_linerange() +
  facet_grid(rows = vars(variable), scale = "free_y") +
  geom_hline(yintercept = 1, linetype = 2) +
  labs(x = "", y = "Odds Ratio\n(95% CI)") +
  theme_bw()

list(
  speech_adjusted,
  swallowing_adjusted,
  strength_adjusted,
  gait_adjusted,
  involuntary_movements_adjusted,
  pain_adjusted,
  falls_adjusted,
  other_adjusted
) |>
  lapply(
    broom::tidy,
    exponentiate = TRUE,
    conf.int = TRUE
  ) |>
  enframe() |>
  mutate(
    symptom = c("Speech", "Swallowing", "Muscle",
                "Gait", "Involuntary\nMovements", "Pain", "Falls",
                "Other Motor")
  ) |>
  unnest(cols = value) |>
  group_by(symptom) |>
  filter(row_number() >= 35) |>
  ungroup() |>
  mutate(
    variable = rep(c("Symptom", "Lives in Urban Area", "Symptom x Lives in Urban Area"), 8)
  ) |>
  mutate(
    symptom = forcats::fct_relevel(
      symptom,
      "Speech", "Swallowing", "Muscle",
      "Gait", "Involuntary\nMovements", "Pain", "Falls",
      "Other Motor"
    ),
    variable = forcats::fct_relevel(
      variable,
      "Symptom", "Lives in Urban Area", "Symptom x Lives in Urban Area"
    )
  ) |>
  ggplot(
    aes(
      x = symptom,
      y = estimate,
      ymin = conf.low,
      ymax = conf.high
    )
  ) + 
  geom_point() +
  geom_linerange() +
  facet_grid(rows = vars(variable), scale = "free_y") +
  geom_hline(yintercept = 1, linetype = 2) +
  labs(x = "", y = "Odds Ratio\n(95% CI)") +
  theme_bw() + 
  scale_y_log10()

ggsave("~/projects/als-sx/fig_1.svg", width = 8, height = 8)

Number of Symptoms

n_symptoms_unadjusted <- clogit(
  number_fml_unadj,
  model_data
)

n_symptoms_unadjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
as.factor(n_total)1 3.00 2.61 3.46
as.factor(n_total)2 9.61 8.27 11.17
as.factor(n_total)3 21.46 18.27 25.22
as.factor(n_total)4 42.06 34.82 50.80
as.factor(n_total)5 66.20 50.74 86.37
as.factor(n_total)6 57.26 39.58 82.82
as.factor(n_total)7 43.86 22.42 85.83
as.factor(n_total)8 26.13 8.41 81.21
lives_in_msaTRUE 1.47 1.31 1.64
as.factor(n_total)1:lives_in_msaTRUE 0.98 0.84 1.14
as.factor(n_total)2:lives_in_msaTRUE 0.80 0.68 0.94
as.factor(n_total)3:lives_in_msaTRUE 0.76 0.64 0.90
as.factor(n_total)4:lives_in_msaTRUE 0.71 0.58 0.87
as.factor(n_total)5:lives_in_msaTRUE 0.62 0.47 0.82
as.factor(n_total)6:lives_in_msaTRUE 0.77 0.52 1.15
as.factor(n_total)7:lives_in_msaTRUE 1.10 0.54 2.26
as.factor(n_total)8:lives_in_msaTRUE NA NA NA
n_symptoms_adjusted <- clogit(
  number_fml_fulladj,
  model_data
)

n_symptoms_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  select(term, estimate, conf.low, conf.high) |>
  knitr::kable(digits = 2)
term estimate conf.low conf.high
rate_outpatient_visits 1.02 1.01 1.02
intensity_outpatient_visits_dx 1.06 1.02 1.10
rate_inpatient_stays 0.79 0.74 0.84
intensity_inpatient_stays_los 0.99 0.99 1.00
elix_CHFTRUE 0.64 0.59 0.69
elix_ValvularTRUE 0.96 0.90 1.02
elix_PHTNTRUE 0.99 0.89 1.09
elix_PVDTRUE 0.84 0.79 0.89
elix_HTNTRUE 0.98 0.94 1.03
elix_HTNcxTRUE 0.90 0.84 0.96
elix_ParalysisTRUE 2.21 2.04 2.39
elix_NeuroOtherTRUE 4.14 3.94 4.34
elix_PulmonaryTRUE 0.94 0.90 0.99
elix_DMTRUE 0.89 0.84 0.94
elix_DMcxTRUE 0.77 0.71 0.84
elix_HypothyroidTRUE 1.09 1.03 1.15
elix_RenalTRUE 0.61 0.56 0.67
elix_LiverTRUE 0.93 0.85 1.01
elix_PUDTRUE 0.98 0.77 1.25
elix_HIVTRUE 1.13 0.78 1.66
elix_LymphomaTRUE 1.24 1.08 1.43
elix_MetsTRUE 0.35 0.30 0.40
elix_TumorTRUE 0.87 0.82 0.93
elix_RheumaticTRUE 1.11 1.03 1.18
elix_CoagulopathyTRUE 0.84 0.77 0.92
elix_ObesityTRUE 0.78 0.73 0.83
elix_WeightLossTRUE 1.55 1.45 1.66
elix_FluidsLytesTRUE 0.74 0.70 0.79
elix_BloodLossTRUE 0.67 0.58 0.76
elix_AnemiaTRUE 1.02 0.96 1.07
elix_AlcoholTRUE 0.86 0.76 0.98
elix_DrugsTRUE 0.80 0.69 0.92
elix_PsychosesTRUE 0.80 0.75 0.85
elix_DepressionTRUE 0.90 0.85 0.95
as.factor(n_total)1 2.63 2.28 3.04
as.factor(n_total)2 7.42 6.35 8.68
as.factor(n_total)3 15.17 12.79 17.99
as.factor(n_total)4 26.65 21.72 32.70
as.factor(n_total)5 33.20 24.80 44.44
as.factor(n_total)6 22.63 14.96 34.23
as.factor(n_total)7 16.36 7.78 34.41
as.factor(n_total)8 7.66 2.29 25.58
lives_in_msaTRUE 1.46 1.30 1.63
as.factor(n_total)1:lives_in_msaTRUE 0.97 0.84 1.14
as.factor(n_total)2:lives_in_msaTRUE 0.79 0.67 0.93
as.factor(n_total)3:lives_in_msaTRUE 0.75 0.63 0.90
as.factor(n_total)4:lives_in_msaTRUE 0.73 0.59 0.91
as.factor(n_total)5:lives_in_msaTRUE 0.67 0.49 0.90
as.factor(n_total)6:lives_in_msaTRUE 0.91 0.58 1.40
as.factor(n_total)7:lives_in_msaTRUE 1.38 0.62 3.06
as.factor(n_total)8:lives_in_msaTRUE NA NA NA
n_symptoms_adjusted |> 
  broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
  filter(!stringr::str_detect(term, "msa"), stringr::str_detect(term, "as.factor")) |>
  mutate(
    variable = 1:8
  ) |>
  ggplot(aes(x = variable, 
             y = estimate,
             ymin = conf.low,
             ymax = conf.high)) + 
  geom_point() + 
  geom_linerange() + 
  labs(x = "Number of Symptoms", y = "ORs Compared to Having No Symptoms\n(95% CI)") + 
  theme_bw()

Excluding Recent “Exposures”

Require the exposure to have occurred at least \(i\) days before the ALS diagnosis or data exit date where \(i\) ranges from 0 days to 5 years.

Since this difference is only defined for people who had a symptom, retain any people who are symptom free if they’re possibly still included in the data (e.g., if the time between the enrollment date and the end date is less than \(i\) days).

First, a couple specific models:

delay_30 <- clogit(
  any_fml_fulladj,
  model_data |>
    filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - 30))) |>
    filter(first_date < (end_date - 30)) |>
    mutate(
      across(
        is_logical,
        as.numeric
      )
    )
  )
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `across(is_logical, as.numeric)`.
Caused by warning:
! Use of bare predicate functions was deprecated in tidyselect 1.1.0.
ℹ Please use wrap predicates in `where()` instead.
  # Was:
  data %>% select(is_logical)

  # Now:
  data %>% select(where(is_logical))
delay_60 <- clogit(
  any_fml_fulladj,
  model_data |>
    filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - 60))) |>
    filter(first_date < (end_date - 60)) |>
    mutate(
      across(
        is_logical,
        as.numeric
      )
    )
  )

delay_90 <- clogit(
  any_fml_fulladj,
  model_data |>
    filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - 90))) |>
    filter(first_date < (end_date - 90)) |>
    mutate(
      across(
        is_logical,
        as.numeric
      )
    )
  )

delay_180 <- clogit(
  any_fml_fulladj,
  model_data |>
    filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - 180))) |>
    filter(first_date < (end_date - 180)) |>
    mutate(
      across(
        is_logical,
        as.numeric
      )
    )
  )

delay_365 <- clogit(
  any_fml_fulladj,
  model_data |>
    filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - 365))) |>
    filter(first_date < (end_date - 365)) |>
    mutate(
      across(
        is_logical,
        as.numeric
      )
    )
  )

glance_vars <- c("nobs","nevent", "concordance", "r.squared")
tbl_merge(
  tbls = list(
    tbl_regression(delay_30, exponentiate = TRUE) |> add_glance_table(glance_vars),
    tbl_regression(delay_60, exponentiate = TRUE) |> add_glance_table(glance_vars),
    tbl_regression(delay_90, exponentiate = TRUE) |> add_glance_table(glance_vars),
    tbl_regression(delay_180, exponentiate = TRUE) |> add_glance_table(glance_vars),
    tbl_regression(delay_365, exponentiate = TRUE) |> add_glance_table(glance_vars)
  ),
  tab_spanner = c("**30 Day Delay**", "**60 Day Delay**", "**90 Day Delay**", 
                  "**180 Day Delay**", "**365 Day Delay**")
) |>
  modify_column_hide(columns = c(p.value_1, p.value_2, p.value_3, p.value_4))
Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
ℹ Please use `all_of()` or `any_of()` instead.
  # Was:
  data %>% select(glance_vars)

  # Now:
  data %>% select(all_of(glance_vars))

See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
Characteristic 30 Day Delay 60 Day Delay 90 Day Delay 180 Day Delay 365 Day Delay
OR1 95% CI1 OR1 95% CI1 OR1 95% CI1 OR1 95% CI1 OR1 95% CI1 p-value
rate_outpatient_visits 1.02 1.02, 1.03 1.03 1.02, 1.03 1.03 1.03, 1.03 1.03 1.03, 1.03 1.03 1.03, 1.03 <0.001
intensity_outpatient_visits_dx 1.14 1.09, 1.18 1.14 1.10, 1.19 1.14 1.10, 1.19 1.13 1.08, 1.17 1.11 1.06, 1.16 <0.001
rate_inpatient_stays 0.78 0.74, 0.83 0.78 0.73, 0.83 0.78 0.73, 0.83 0.78 0.73, 0.83 0.79 0.73, 0.85 <0.001
intensity_inpatient_stays_los 1.00 0.99, 1.00 1.00 0.99, 1.00 1.00 0.99, 1.00 1.00 0.99, 1.00 1.00 0.99, 1.01 >0.9
elix_CHF 0.63 0.59, 0.68 0.64 0.59, 0.69 0.63 0.58, 0.68 0.63 0.58, 0.68 0.64 0.59, 0.70 <0.001
elix_Valvular 0.97 0.92, 1.03 0.97 0.91, 1.02 0.97 0.92, 1.03 0.97 0.91, 1.03 0.98 0.92, 1.04 0.5
elix_PHTN 0.98 0.89, 1.09 0.98 0.89, 1.09 0.99 0.90, 1.10 1.01 0.91, 1.12 0.98 0.88, 1.10 0.8
elix_PVD 0.92 0.87, 0.98 0.94 0.88, 0.99 0.94 0.88, 1.0 0.92 0.87, 0.98 0.91 0.86, 0.98 0.008
elix_HTN 0.99 0.95, 1.03 1.00 0.95, 1.04 1.00 0.96, 1.05 1.01 0.97, 1.06 1.01 0.96, 1.07 0.6
elix_HTNcx 0.91 0.85, 0.97 0.91 0.86, 0.97 0.91 0.85, 0.97 0.91 0.85, 0.97 0.91 0.84, 0.97 0.007
elix_Paralysis 2.99 2.77, 3.23 2.95 2.72, 3.19 2.94 2.72, 3.19 2.93 2.70, 3.18 2.89 2.65, 3.16 <0.001
elix_NeuroOther 5.28 5.05, 5.53 5.33 5.09, 5.58 5.33 5.09, 5.59 5.26 5.00, 5.52 5.09 4.83, 5.37 <0.001
elix_Pulmonary 0.96 0.91, 1.00 0.95 0.91, 1.00 0.96 0.91, 1.00 0.97 0.93, 1.02 0.99 0.94, 1.04 0.8
elix_DM 0.87 0.82, 0.92 0.88 0.83, 0.93 0.89 0.84, 0.94 0.89 0.84, 0.95 0.91 0.86, 0.97 0.004
elix_DMcx 0.79 0.73, 0.86 0.79 0.73, 0.85 0.78 0.72, 0.85 0.78 0.72, 0.85 0.77 0.70, 0.84 <0.001
elix_Hypothyroid 1.11 1.05, 1.16 1.10 1.05, 1.16 1.09 1.04, 1.15 1.09 1.03, 1.15 1.10 1.04, 1.16 0.001
elix_Renal 0.58 0.53, 0.64 0.58 0.53, 0.63 0.58 0.53, 0.63 0.59 0.53, 0.65 0.58 0.53, 0.65 <0.001
elix_Liver 0.93 0.86, 1.01 0.93 0.86, 1.01 0.94 0.86, 1.02 0.92 0.85, 1.01 0.95 0.86, 1.04 0.2
elix_PUD 1.01 0.80, 1.27 1.01 0.80, 1.27 0.96 0.76, 1.21 1.00 0.79, 1.27 0.99 0.77, 1.27 >0.9
elix_HIV 1.01 0.70, 1.45 1.02 0.71, 1.48 1.07 0.74, 1.55 1.04 0.72, 1.52 1.07 0.72, 1.58 0.7
elix_Lymphoma 1.24 1.08, 1.42 1.18 1.03, 1.36 1.19 1.03, 1.38 1.21 1.04, 1.40 1.18 1.01, 1.38 0.033
elix_Mets 0.33 0.29, 0.38 0.34 0.30, 0.39 0.34 0.30, 0.39 0.35 0.31, 0.41 0.39 0.34, 0.45 <0.001
elix_Tumor 0.86 0.81, 0.91 0.86 0.81, 0.92 0.88 0.82, 0.93 0.89 0.83, 0.95 0.89 0.83, 0.95 <0.001
elix_Rheumatic 1.25 1.17, 1.33 1.26 1.18, 1.35 1.26 1.19, 1.35 1.26 1.18, 1.35 1.27 1.19, 1.36 <0.001
elix_Coagulopathy 0.85 0.78, 0.93 0.85 0.78, 0.93 0.85 0.78, 0.93 0.86 0.78, 0.94 0.84 0.76, 0.92 <0.001
elix_Obesity 0.83 0.79, 0.89 0.85 0.80, 0.90 0.86 0.80, 0.91 0.86 0.81, 0.92 0.87 0.81, 0.93 <0.001
elix_WeightLoss 1.65 1.55, 1.76 1.62 1.52, 1.73 1.63 1.52, 1.74 1.58 1.48, 1.70 1.54 1.43, 1.66 <0.001
elix_FluidsLytes 0.79 0.75, 0.84 0.80 0.76, 0.85 0.80 0.75, 0.85 0.81 0.76, 0.86 0.81 0.76, 0.86 <0.001
elix_BloodLoss 0.70 0.61, 0.79 0.69 0.61, 0.79 0.70 0.62, 0.80 0.72 0.63, 0.82 0.73 0.63, 0.83 <0.001
elix_Anemia 1.05 1.00, 1.11 1.06 1.00, 1.11 1.06 1.00, 1.11 1.05 1.00, 1.11 1.06 1.00, 1.12 0.057
elix_Alcohol 0.83 0.73, 0.93 0.83 0.74, 0.94 0.84 0.74, 0.95 0.85 0.75, 0.97 0.85 0.74, 0.97 0.016
elix_Drugs 0.82 0.71, 0.94 0.82 0.71, 0.95 0.82 0.71, 0.95 0.82 0.71, 0.96 0.81 0.69, 0.95 0.008
elix_Psychoses 0.82 0.77, 0.87 0.82 0.76, 0.87 0.82 0.77, 0.88 0.83 0.78, 0.89 0.84 0.78, 0.90 <0.001
elix_Depression 0.98 0.92, 1.03 0.98 0.93, 1.04 0.98 0.93, 1.03 0.97 0.92, 1.03 0.98 0.93, 1.05 0.6
any_sx 4.49 3.97, 5.07 4.20 3.71, 4.75 3.98 3.51, 4.50 3.56 3.14, 4.04 3.08 2.70, 3.51 <0.001
lives_in_msa 1.42 1.27, 1.60 1.42 1.27, 1.59 1.42 1.26, 1.59 1.41 1.26, 1.58 1.40 1.25, 1.58 <0.001
any_sx * lives_in_msa 0.83 0.73, 0.95 0.83 0.73, 0.95 0.83 0.73, 0.95 0.84 0.73, 0.96 0.85 0.74, 0.97 0.017
No. Obs. 113,827 112,410 111,062 107,147 98,850
N events 18,342 17,615 17,016 15,574 13,418
c-index 0.795 0.794 0.793 0.789 0.778
0.150 0.146 0.142 0.133 0.117
1 OR = Odds Ratio, CI = Confidence Interval

And then with all the lags up to 5 years:

lags <- round(seq(0, 2, by = 1/12) * 365)
results <- vector("list", length(lags))
j <- 1
p <- progress::progress_bar$new(
  total = length(lags), 
  format = "[:bar] :percent in :elapsed with :eta remaining"
)
for (i in lags) {
  results[[j]] <- clogit(
    any_fml_fulladj,
    model_data |>
      filter(is.na(first_symptom_date) | (first_symptom_date < (end_date - i))) |>
      filter(first_date < (end_date - i))
    ) |> 
      broom::tidy(exponentiate = TRUE, conf.int = TRUE) |>
      mutate(i = i) |>
      select(i, term, estimate, conf.low, conf.high)
    j <- j + 1
    p$tick()
}

results |>
  bind_rows() |> 
  filter(
    stringr::str_detect(term, "Neuro")
  ) |>
  ggplot(aes(x = i / 365, 
             y = estimate,
             ymin = conf.low,
             ymax = conf.high)) + 
  geom_point() +
  geom_linerange() + 
  labs(x = "Lead-in Period by Years",
       y = "Odds Ratio for Elixhauser Neurological CMs") + 
  theme_bw()

ggsave("~/projects/als-sx/neuro_series.svg", width = 16/2, height = 9/2)

results |>
  bind_rows() |> 
  filter(
    stringr::str_detect(term, "sx") | stringr::str_detect(term, "msa")
  ) |>
  mutate(
    term = case_when(
      term == "any_sxTRUE" ~ "Has Symptom",
      term == "lives_in_msaTRUE" ~ "Lives in MSA",
      term == "any_sxTRUE:lives_in_msaTRUE" ~ "Symptom x MSA"
    ),
    term = forcats::fct_relevel(term,
      "Has Symptom", "Lives in MSA")
  ) |>
  ggplot(
    aes(
      x = i / 365,
      y = estimate,
      ymin = conf.low,
      ymax = conf.high
    )
  ) + 
  geom_point() + 
  geom_linerange() + 
  facet_grid(rows = vars(term), scales = "free_y") + 
  labs(x = "Years Between Symptom and ALS Date", y = "Odds Ratio") +
  theme_bw()

ggsave("~/projects/als-sx/symptom_series.svg", width = 16/2, height = 9/2)