Skip to content

Commit

Permalink
Merge pull request #84 from istallworthy/run-through
Browse files Browse the repository at this point in the history
clean up
  • Loading branch information
istallworthy authored Sep 20, 2023
2 parents f6265a4 + db49136 commit 46b2b3c
Show file tree
Hide file tree
Showing 29 changed files with 56 additions and 5,952 deletions.
3,460 changes: 0 additions & 3,460 deletions !Archive/HOMEETA1_sqrtSAAR_for_Mplus.csv

This file was deleted.

Binary file removed !Archive/MSM Pipeline and Package.docx
Binary file not shown.
19 changes: 0 additions & 19 deletions !Archive/Mplus Run Models.log

This file was deleted.

321 changes: 0 additions & 321 deletions !Archive/examplePipeline.Rmd

This file was deleted.

351 changes: 0 additions & 351 deletions !Archive/examplePipelineBinExp.Rmd

This file was deleted.

250 changes: 0 additions & 250 deletions !Archive/examplePipelineTutorial copy.Rmd

This file was deleted.

250 changes: 0 additions & 250 deletions !Archive/examplePipelineTutorial.Rmd

This file was deleted.

333 changes: 0 additions & 333 deletions !Archive/examplePipeline_MD.Rmd

This file was deleted.

355 changes: 0 additions & 355 deletions !Archive/examplePipeline_MD_10.17.22.Rmd

This file was deleted.

409 changes: 0 additions & 409 deletions !Archive/makeMplusInputs.R

This file was deleted.

26 changes: 0 additions & 26 deletions !Archive/mplusObject.R

This file was deleted.

16 changes: 0 additions & 16 deletions !Archive/weightedMixedModels.R

This file was deleted.

128 changes: 0 additions & 128 deletions !Archive/write.inp.file.R

This file was deleted.

Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ docs
.Rdata
.httr-oauth
.DS_Store
!Archive/*
Archive/*
29 changes: 19 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@ Package: devMSMs
Type: Package
Title: Tools for Conducting Marginal Structural Models with Developmental Data
Version: 0.0.0.9000
Authors: Isabella Stallworthy
Authors@R: c(person("Isabella", "Stallworthy",
email = "[email protected]",
role = c("aut", "cre")),
person("Meriah", "DeJoseph",
email = "[email protected]",
role = c("aut")),
person("Emily", "Padrutt",
email = "[email protected]",
role = c("aut")),
person("Noah", "Greifer",
email = "[email protected]",
role = c("aut")),
person("Daniel", "Berry",
email = "[email protected]",
role = c("aut")))
Description: Functions for preparing, assessing, and implementing MSMS.
License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
Imports:
readr,
readxl,
tidyr,
dplyr,
WeightIt,
MatchThem,
marginaleffects,
ranger,
data.table,
tidyr,
Hmisc,
stats,
ggplot2,
matrixStats,
Expand All @@ -33,12 +41,13 @@ Imports:
doRNG,
foreach,
mice,
sjPlot,
stargazer,
gtools,
RColorBrewer,
cobalt,
dbarts
purrr,
stringr,
missMethods,
tibble
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ importFrom(mice,complete)
importFrom(mice,ibind)
importFrom(mice,mice)
importFrom(mice,pool)
importFrom(missMethods,delete_MAR_1_to_x)
importFrom(parallel,detectCores)
importFrom(purrr,map_dfr)
importFrom(stargazer,stargazer)
Expand Down
4 changes: 2 additions & 2 deletions R/fitModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ fitModel <- function(home_dir, data, weights, exposure, exposure_time_pts, outco
}

if (save.out){
require(officer) #is there another way to do this? required for writing to word
require(flextable) # " "
requireNamespace(officer) #is there another way to do this? required for writing to word
requireNamespace(flextable) # " "
suppressWarnings(jtools::export_summs(fits, to.file = "docx", statistics = c(N = "nobs", AIC = "AIC", R2 = "r.squared"),
file.name = file.path(home_dir, "models", paste0(exposure, "-", outcome, "_", model,
"_table_mod_ev.docx"))))
Expand Down
2 changes: 1 addition & 1 deletion R/getModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' @param covariates list of characters reflecting variable names of covariates
#' for covariate models
#' @param verbose TRUE or FALSE indicator for user output (default is TRUE)
#' @importFrom survey svyglm
#' @return list of fitted model(s)
#' @export
#' @examples
Expand Down Expand Up @@ -86,7 +87,6 @@ getModel <- function(d, exposure, exposure_time_pts, outcome, epochs, exp_epochs
#finds data from each time point in each epoch, horizontally aligns all exposure values within the epoch for averaging
for (l in seq_len(length(as.numeric(unlist(epochs[e, 2]))))){
level <- as.numeric(unlist(epochs[e, 2]))[l]
# z <- d[, which(grepl(paste0(exposure, ".", level), names(d)))]
z <- d[, names(d)[grepl(exposure, names(d))]] #finds exposure vars
z <- as.numeric(as.character(unlist(z[, sapply(strsplit(names(z), "\\."), "[", 2) == as.character(level)])))
temp <- cbind(temp, z)
Expand Down
6 changes: 4 additions & 2 deletions R/imputeData.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @importFrom purrr map_dfr
#' @importFrom foreach getDoParWorkers
#' @importFrom foreach getDoParName
#' @importFrom missMethods delete_MAR_1_to_x
#' @seealso {[mice::mice()],
#' <https://cran.r-project.org/web/packages/mice/index.html>}
#' @param data data in wide format
Expand All @@ -29,7 +30,7 @@
#' using multiple cores to speed up process (default = TRUE)
#' @param save.out (optional) TRUE or FALSE indicator to save output and
#' intermediary output locally (default is TRUE)
#' @param read_in_from_file (optional) "yes" or "no" indicatorto read in weights
#' @param read_imps_from_file (optional) "yes" or "no" indicatorto read in weights
#' that have been previously run and saved locally (default is "no")
#' @return mice object of m imputed datasets
#' @examples
Expand All @@ -45,7 +46,8 @@
#' test[, c("A.1", "A.2", "A.3")] <- lapply(test[, c("A.1", "A.2", "A.3")], as.numeric)
#'
#' test_miss <- missMethods::delete_MAR_1_to_x(as.data.frame(test), p = 0.20,
#' cols_mis = c("A.1", "B.2", "C"), cols_ctrl = c("B.1", "B.1", "B.1"), 3)
#' cols_mis = c("A.1", "B.2", "C"),
#' cols_ctrl = c("B.1", "B.1", "B.1"), 3)
#' test_i <- imputeData(data = test_miss,
#' m = 3,
#' method = "rf",
Expand Down
4 changes: 2 additions & 2 deletions R/inspectData.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#' @param hi_lo_cut (optional) list of two numbers indicating quantile values
#' that reflect high and low values, respectively, for continuous exposure
#' (default is median split)
#' @param (optional) reference string of "-"-separated "l" and "h" values
#' @param reference (optional)string of "-"-separated "l" and "h" values
#' indicative of a reference exposure history to which to compare comparison,
#' required if comparison is specified
#' @param (optional) comparison list of one or more strings of "-"-separated "l"
#' @param comparison (optional)list of one or more strings of "-"-separated "l"
#' and "h" values indicative of comparison history/histories to compare to
#' reference, required if reference is specified
#' @param verbose (optional) TRUE or FALSE indicator for user output (default is
Expand Down
2 changes: 2 additions & 0 deletions R/make_love_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#' @param weights_method method character string of WeightItMSM() balancing
#' method abbreviation
#' @param imp_conf list of variable names reflecting important confounders
#' @param verbose TRUE or FALSE indicator for user output (default is
#' TRUE)
#' @param save.out TRUE or FALSE indicator to save output and intermediary
#' output locally
#' @return none
Expand Down
5 changes: 3 additions & 2 deletions R/trimWeights.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#' Trims IPTW balancing weights with heavy right tails by populating all weight
#' values above a given quantile with the weight value of that quantile.
#'
#' @seealso {[WeightIt::trim()],
#' <https://search.r-project.org/CRAN/refmans/WeightIt/html/trim.html>}
#' @seealso [WeightIt::trim()],
#' <https://search.r-project.org/CRAN/refmans/WeightIt/html/trim.html> which
#' this function wraps
#' @param home_dir path to home directory
#' @param exposure name of exposure variable
#' @param outcome name of outcome variable with ".timepoint" suffix
Expand Down
4 changes: 0 additions & 4 deletions _pkgdown.yml

This file was deleted.

2 changes: 2 additions & 0 deletions examplePipelineRevised.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ library(devMSMs)
# remove.packages("devMSMs")
#prior to re-installing using the code above. Sorry, this is annoying!
#conducting package checks & tests from documentation
devtools::check()
```


Expand Down
9 changes: 5 additions & 4 deletions man/imputeData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46b2b3c

Please sign in to comment.