build_model_data.knit

title: “Build Model Data Sets for Propensity Score Model Estimation” description: |
author: - name: Jacob Simmering, PhD url: https://jacobsimmering.com affiliation: University of Iowa affiliation_url: https://uiowa.edu date: “2022-12-02” output: distill::distill_article

This file was compiled on 2022-12-02 11:02:42 by jsimmeri on argon-lc-h18-40.hpc.

All of the libraries we need and functions we will use are defined in etl/add_covariates_functions.R. We’ll use source() to load that into our current R session:

source("~/projects/pdd/etl/add_covariates_functions.R")

We then use add_covariates(cohort) with cohort values of bph_rx.

bph_start_time <- now()
bph_rx_model_data <- add_covariates("bph_rx")
bph_end_time <- now()

That extraction took 8.52716752290726 to complete.

We want to remove anyone with a dementia diagnosis before the index date:

bph_rx_model_data <- bph_rx_model_data %>%
  filter(is.na(event_date) | event_date > index_date)

We also want to require that the dementia diagnosis happens after the PD diagnosis

bph_rx_model_data <- bph_rx_model_data %>%
  mutate(pd_date = start_date + pd_days) %>%
  filter(pd_date < event_date | is.na(event_date))

And then we write out the data to each respective sub-directory:

write_rds(bph_rx_model_data,
          "/Shared/lss_jsimmeri_backup/data/pdd/bph_rx/model_data.rds")
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /cvmfs/argon.hpc.uiowa.edu/2022.1/apps/linux-centos7-x86_64/gcc-9.4.0/intel-oneapi-mkl-2022.0.2-s35g6hp/mkl/2022.0.2/lib/intel64/libmkl_gf_lp64.so.2

locale:
[1] C

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets 
[7] methods   base     

other attached packages:
 [1] icd_4.0.9.9000  lubridate_1.8.0 forcats_0.5.2   stringr_1.4.1  
 [5] dplyr_1.0.10    purrr_0.3.4     readr_2.1.2     tidyr_1.2.0    
 [9] tibble_3.1.8    ggplot2_3.3.6   tidyverse_1.3.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9          statepi_0.0.1       prettyunits_1.1.1  
 [4] assertthat_0.2.1    digest_0.6.29       utf8_1.2.2         
 [7] R6_2.5.1            cellranger_1.1.0    backports_1.4.1    
[10] reprex_2.0.2        evaluate_0.16       httr_1.4.4         
[13] pillar_1.8.1        progress_1.2.2      rlang_1.0.6        
[16] googlesheets4_1.0.1 readxl_1.4.1        jquerylib_0.1.4    
[19] rmarkdown_2.16      googledrive_2.0.0   munsell_0.5.0      
[22] broom_1.0.1         compiler_4.1.3      modelr_0.1.9       
[25] xfun_0.32           pkgconfig_2.0.3     htmltools_0.5.3    
[28] downlit_0.4.2       tidyselect_1.1.2    fansi_1.0.3        
[31] crayon_1.5.1        tzdb_0.3.0          dbplyr_2.2.1       
[34] withr_2.5.0         grid_4.1.3          jsonlite_1.8.0     
[37] gtable_0.3.1        lifecycle_1.0.1     DBI_1.1.3          
[40] magrittr_2.0.3      scales_1.2.1        cli_3.4.1          
[43] stringi_1.7.8       cachem_1.0.6        fs_1.5.2           
[46] xml2_1.3.3          bslib_0.4.0         ellipsis_0.3.2     
[49] generics_0.1.3      vctrs_0.4.1         distill_1.5        
[52] tools_4.1.3         glue_1.6.2          hms_1.1.2          
[55] fastmap_1.1.0       yaml_2.3.5          colorspace_2.0-3   
[58] gargle_1.2.0        rvest_1.0.3         memoise_2.0.1      
[61] knitr_1.40          haven_2.5.1         sass_0.4.2