diff --git a/NAMESPACE b/NAMESPACE index 900cb0b9..9da52b43 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,5 +15,4 @@ export(make_love_plot) export(trimWeights) import(ggplot2) import(stats) -import(utils) importFrom(survey,svyglm) diff --git a/data/sim_data_long_miss_bin.rda b/data/sim_data_long_miss_bin.rda new file mode 100644 index 00000000..d8dea891 Binary files /dev/null and b/data/sim_data_long_miss_bin.rda differ diff --git a/data/sim_data_wide.rda b/data/sim_data_wide.rda index 6f579e61..38996b22 100644 Binary files a/data/sim_data_wide.rda and b/data/sim_data_wide.rda differ diff --git a/data/sim_data_wide_bin.rda b/data/sim_data_wide_bin.rda new file mode 100644 index 00000000..59371e87 Binary files /dev/null and b/data/sim_data_wide_bin.rda differ diff --git a/data/sim_data_wide_miss.rda b/data/sim_data_wide_miss.rda index 5470a76b..1a424c4f 100644 Binary files a/data/sim_data_wide_miss.rda and b/data/sim_data_wide_miss.rda differ diff --git a/data/sim_data_wide_miss_bin.rda b/data/sim_data_wide_miss_bin.rda new file mode 100644 index 00000000..bf4161df Binary files /dev/null and b/data/sim_data_wide_miss_bin.rda differ diff --git a/examplePipelineRevised.Rmd b/examplePipelineRevised.Rmd index c4dbc57a..f794a4ce 100644 --- a/examplePipelineRevised.Rmd +++ b/examplePipelineRevised.Rmd @@ -192,7 +192,7 @@ data <- data_wide #optional; number of imputations (default is 5) m <- NA -m <- 5 #empirical example +m <- 1 #empirical example #optional; provide an imputation method pmm, midastouch, sample, cart , rf (default) method <- NA @@ -214,7 +214,10 @@ imputed_data <- imputeData(data = data_wide, exposure = exposure, outcome = outc #if you want to use the package with imputed data data <- imputed_data - +``` + + +```{r} #OR, read in a saved mids object imputed_data <- readRDS("/Users/isabella/Library/CloudStorage/Box-Box/BSL General/MSMs/testing/testing data/continuous outcome/continuous exposure/FLP_wide_imputed_mids.rds") # final imputations for empirical example; place your .rds file in your home directory and change the name of file here diff --git a/vignettes/Data_Requirements.Rmd b/vignettes/Data_Requirements.Rmd index eff9307d..ab985b1a 100644 --- a/vignettes/Data_Requirements.Rmd +++ b/vignettes/Data_Requirements.Rmd @@ -45,9 +45,9 @@ We advise the user to specify and include in the dataset any time invariant and The following longitudinal data that accompany *devMSMs* are simulated based on data from the Family Life Project (FLP), a longitudinal study following 1,292 families representative of two geographic areas (three counties in North Carolina and three counties in Pennsylvania) with high rural child poverty (Vernon-Feagans et al., 2013; Burchinal et al., 2008). -*devMSMs* requires data in wide format (i.e., one row per individual, with and “ID” column for identifiers), in one of three ways: +*devMSMs* (see *Workflows* vignettes) requires complete data in wide format (i.e., one row per individual, with and “ID” column for identifiers), in one of three ways: -(1) a data frame with no missing data; +(1) a single data frame with no missing data; ```{r} data("sim_data_wide", package = "devMSMs") diff --git a/vignettes/Preliminary_Steps.Rmd b/vignettes/Preliminary_Steps.Rmd index cd4597b1..4ab1acbe 100644 --- a/vignettes/Preliminary_Steps.Rmd +++ b/vignettes/Preliminary_Steps.Rmd @@ -22,10 +22,13 @@ knitr::opts_chunk$set( options(rmarkdown.html_vignette.check_title = FALSE) ``` +
- -These four recommended preliminary steps are designed to assist the user in preparing and inspecting their data to ensure appropriate use of the package. Users should first view the Terminology vignette and complete the Data Requirements and Specifying Core Inputs vignettes. The following recommended preliminary steps (using helper functions summarized in Table 1 are not included in the *devMSMs* package that can be found at the following Github are designed to assist the user in preparing and inspecting their data and guide specification of required function inputs to ensure appropriate use of the package. Of note, *devMSMs* must also be installed and loaded to use these helper functions (see Installation). - + +These four recommended preliminary steps are designed to assist the user in preparing and inspecting their data to ensure appropriate use of the package. Users should first view the Terminology vignette and complete the Data Requirements and Specifying Core Inputs vignettes. + +The following recommended preliminary steps (using helper functions summarized in Table 1 are not included in the *devMSMs* package that can be found at the following Github are designed to assist the user in preparing and inspecting their data and guide specification of required function inputs to ensure appropriate use of the package. Of note, *devMSMs* must also be installed and loaded to use these helper functions (see Installation). + The user who has already formatted their data in wide format according to the Data Requirements vignette and imputed to accommodate any missing data (P2), can focus only on subsections P3 Identifying Optional Exposure Epochs and P4 Verifying History Distributions prior to using the package. Following completion of this vignette, users should use one of the Workflows vignettes to implement *devMSMs* with their longitudinal data. diff --git a/vignettes/Specify_Core_Inputs.Rmd b/vignettes/Specify_Core_Inputs.Rmd index d767c4f5..9cb9d483 100644 --- a/vignettes/Specify_Core_Inputs.Rmd +++ b/vignettes/Specify_Core_Inputs.Rmd @@ -19,7 +19,7 @@ knitr::opts_chunk$set( ) ``` -This vignette guides users through the specification of the core inputs required by the *deMSMs* functions (and helper functions). Users should first view the Terminology and Data Requirements vignettes. This vignette helps users specify core inputs (e.g., home directory, exposure, exposure time points, time-varying confounders, time invariant confounders, outcome, reference, comparison, high/low cutoff for continuous exposure, and balance threshold) that are used by multiple functions in the *devMSMs* package (see *Workflows* vignettes). Their use and values should be kept consistent throughout the package. Additionally, all functions have two optional inputs allowing the user to override defaults to suppress all messaging to the console (`verbose = FALSE`) and elect not to save out locally any intermediate and final output (`save.out = FALSE`). +This vignette guides users through the specification of the core inputs required by the *deMSMs* functions (and helper functions). Users should first view the Terminology and Data Requirements vignettes. This vignette helps users specify core inputs (e.g., home directory, exposure, exposure time points, time-varying confounders, time invariant confounders, outcome, reference, comparison, high/low cutoff for continuous exposure, and balance threshold) that are used by multiple functions in the *devMSMs* package (see *Workflows* vignettes). Their use and values should be kept consistent throughout the package. Additionally, all functions have two optional inputs allowing the user to override defaults to suppress all messaging to the console (`verbose = FALSE`) and elect not to save out locally any intermediate and final output (`save.out = FALSE`). Following completion of this vignette, the user should complete the Preliminary Steps followed by a *Workflow* vignette to implement *devMSMs* with their longitudinal data. @@ -35,6 +35,7 @@ Users are required to specify home directory, or in quotations, a path to a desi home_dir <- NA home_dir <- '/Users/isabella/Library/CloudStorage/Box-Box/BSL General/MSMs/testing/isa' #note: no / after ``` +
### Exposure Variable @@ -43,6 +44,7 @@ Users are required to specify an exposure variable as input to all functions in ```{r} exposure <- "ESETA1" ``` +
### Exposure Time Points @@ -108,6 +110,7 @@ tv_confounders <- c("SAAmylase.6","SAAmylase.15", "SAAmylase.24", "fscore.35", "fscore.58" ) ``` +
### References diff --git a/vignettes/Workflow_Continuous_Exposure.Rmd b/vignettes/Workflow_Continuous_Exposure.Rmd index 2df0aa2e..01698d33 100644 --- a/vignettes/Workflow_Continuous_Exposure.Rmd +++ b/vignettes/Workflow_Continuous_Exposure.Rmd @@ -34,9 +34,9 @@ library(devMSMsHelpers) ```
-This vignette guides a user through the process of using *devMSMs* with a continuously distributed exposure variable. The users should first view the Terminology, Data Requirements, Specifying Core Inputs, and Preliminary Steps vignettes. +This vignette guides a user through the process of using *devMSMs* to fit marginal structural models (MSMs) with a a continuously distributed exposure variable. The users should first view the Terminology, Data Requirements, Specifying Core Inputs, and Preliminary Steps vignettes. -The following suggested workflow and constituent steps are also reflected in examplePipeline.rmd file. This workflow is designed to complement the conceptual and high-level practical details provided in the manuscript *[add link here]*. We strongly suggest users familiarize themselves with concepts of the MSM process outlined in the manuscript and the practical steps and functions put forth in the following sections before implementing this workflow. +The following suggested workflow and constituent steps are also reflected in examplePipeline.rmd file. This workflow is designed to complement the conceptual and high-level practical details provided in the manuscript *[add link here]*. We strongly suggest users familiarize themselves with concepts of the MSM process outlined in the manuscript and the practical steps and functions put forth in the following sections before implementing this workflow. All *devMSMs* functions have optional arguments to suppress saving output locally (`save.out = FALSE`) and printing it to the console (`verbose = FALSE`). The defaults to both arguments are TRUE, as recommended for use of the package's full functionality. Users must supply a path to a home directory (`home_dir`) if `save.out = TRUE`. All sub-folders referenced by each function are created automatically within the home directory. @@ -45,6 +45,7 @@ save.out = FALSE verbose = TRUE ``` +
### Load data @@ -96,6 +97,7 @@ ti_confounders <- c("state", "BioDadInHH2", "PmAge2", "PmBlac2", "TcBlac2", "PmM "peri_health", "caregiv_health", "gov_assist" ) ``` +
## Phase 1: Confounder Adjustment