diff --git a/DESCRIPTION b/DESCRIPTION index 42eb8642..4d90845e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,58 +1,43 @@ Package: devMSMs Type: Package Title: Implementing Marginal Structural Models with Longitudinal Data -Version: 0.0.0.9000 -Authors@R: c(person("Isabella", "Stallworthy", - email = "istall@seas.upenn.edu", - role = c("aut", "cre")), - person("Noah", "Greifer", - email = "ngreifer@iq.harvard.edu", - role = c("aut", "ctb")), - person("Kyle", "Butts", - email = "buttskyle96@gmail.com", - role = ("ctb")), - person("Meriah", "DeJoseph", - email = "meriahd@stanford.edu", - role = c("aut")), - person("Emily", "Padrutt", - email = "padru004@umn.edu", - role = c("aut")), - person("Daniel", "Berry", - email = "dberry@umn.edu", - role = c("aut"))) +Version: 0.0.0.9001 +Authors@R: c(person("Isabella", "Stallworthy", email = "istall@seas.upenn.edu", role = c("aut", "cre")), + person("Noah", "Greifer", email = "noah.greifer@gmail.com", role = c("aut", "ctb"), + comment=c(ORCID="0000-0003-3067-7154")), + person("Kyle", "Butts", email = "buttskyle96@gmail.com", role = ("ctb")), + person("Meriah", "DeJoseph", email = "meriahd@stanford.edu", role = c("aut")), + person("Emily", "Padrutt", email = "padru004@umn.edu", role = c("aut")), + person("Daniel", "Berry", email = "dberry@umn.edu", role = c("aut"))) Description: Functions for implementing MSMS with longitudinal data. License: GPL-3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Imports: - cobalt, - dreamerr, - ggplot2, - marginaleffects, - markdown, + cobalt (>= 4.5.0), + dreamerr (>= 1.4.0), + fs (>= 1.6.4), + ggplot2 (>= 3.5.1), + lmtest (>= 0.9-40), + marginaleffects (>= 0.21.0), modelsummary, rlang, stats, - survey, tinytable, - WeightIt, - utils, - fs + WeightIt (>= 1.2.0), + utils Suggests: - CBPS, dbarts, gbm, knitr, mice, - mitml, rmarkdown, SuperLearner, - webshot2, testthat (>= 3.0.0) Config/testthat/edition: 3 URL: https://istallworthy.github.io/devMSMs/, https://github.com/istallworthy/devMSMs VignetteBuilder: knitr Depends: - R (>= 2.10) + R (>= 4.0.0) diff --git a/NAMESPACE b/NAMESPACE index 99a526c1..8702cc84 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,7 @@ S3method(print,devMSM_models) S3method(print,devMSM_weights) S3method(summary,devMSM_bal_stats) S3method(summary,devMSM_comparisons) +S3method(summary,devMSM_weights) export(assessBalance) export(compareHistories) export(createFormulas) @@ -18,7 +19,6 @@ export(createWeights) export(fitModel) export(initMSM) export(trimWeights) -import(ggplot2) import(stats) import(utils) -importFrom(survey,svyglm) +importFrom(ggplot2,.data) diff --git a/man/assessBalance.Rd b/man/assessBalance.Rd index ac4dda49..9725fc9f 100644 --- a/man/assessBalance.Rd +++ b/man/assessBalance.Rd @@ -19,7 +19,7 @@ assessBalance( \method{print}{devMSM_bal_stats}(x, i = NA, t = TRUE, save.out = FALSE, ...) -\method{summary}{devMSM_bal_stats}(object, i = NA, t = TRUE, save.out = FALSE, ...) +\method{summary}{devMSM_bal_stats}(object, i = NA, save.out = FALSE, ...) \method{plot}{devMSM_bal_stats}(x, i = NA, t = TRUE, save.out = FALSE, ...) } @@ -49,11 +49,11 @@ default is FALSE.} \item{x}{devMSM_bal_stats object from \code{assessBalance}} -\item{i}{For multiply imputed datset, \code{i} selects which imputation to print results for. -Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that.} +\item{i}{For multiply imputed datasets, \code{i} selects which imputation to print results for. +Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that. Ignored for non-imputed data.} -\item{t}{Which exposure variable to use. Can either be an index from 1, ..., num exposures or -a string containing the exposure varaible name (e.g. \code{"A.3"}). With \code{t = TRUE}, all exposure +\item{t}{Which exposure variable to use. Can either be an index from 1 to the number of exposures or +a string containing the exposure variable name (e.g. \code{"A.3"}). With \code{t = TRUE}, all exposure variables will be looped over.} \item{...}{ignored} @@ -102,8 +102,8 @@ plot(b, t = 3) # Weighted f <- createFormulas(obj, type = "short") -w <- createWeights(data = data, obj = obj, formulas = f) -bw <- assessBalance(data = data, obj = obj, weights = w) +w <- createWeights(data = data, formulas = f) +bw <- assessBalance(data = data, weights = w) print(bw) plot(bw) diff --git a/man/calc_bal_stats.Rd b/man/calc_bal_stats.Rd deleted file mode 100644 index 0c969318..00000000 --- a/man/calc_bal_stats.Rd +++ /dev/null @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calc_bal_stats.R -\name{calc_bal_stats} -\alias{calc_bal_stats} -\title{Calculate balance stats based on Jackson paper} -\usage{ -calc_bal_stats( - data, - obj, - weights = NULL, - balance_thresh = NULL, - imp_conf = NULL -) -} -\arguments{ -\item{data}{data in wide format as: a data frame, path to folder of imputed -.csv files, or mids object} - -\item{obj}{initialized MSM object from \code{initMSM}} - -\item{weights}{(optional) list of IPTW weights output from createWeights} - -\item{balance_thresh}{(optional) one or two numbers between 0 and 1 -indicating a single balancingn threshold or thresholds for more and less -important confounders, respectively} - -\item{imp_conf}{(optional) list of variable names reflecting important -confounders (required if two balance thresholds are provided)} -} -\value{ -data frame of balance statistics -} -\description{ -Calculate weighted or unweighted standardized balance statistics for a given -exposure time point, using all relevant confounders. Draws on Jackson, 2016 -approaches to assessing balance for time-varying exposures by weighting -statistics based on sample distribution in exposure histories. -} -\keyword{internal} diff --git a/man/compareHistories.Rd b/man/compareHistories.Rd index 7de9d44d..91a1d41c 100644 --- a/man/compareHistories.Rd +++ b/man/compareHistories.Rd @@ -8,13 +8,12 @@ \title{Estimate, compare, and visualize exposure histories} \usage{ compareHistories( - obj, fit, hi_lo_cut = c(0.4, 0.6), - dose_level = c("h", "l"), + dose_level = "h", reference = NULL, comparison = NULL, - mc_comp_method = stats::p.adjust.methods, + mc_comp_method = "BH", verbose = FALSE, save.out = FALSE ) @@ -30,11 +29,9 @@ compareHistories( ... ) -\method{summary}{devMSM_comparisons}(object, type = c("preds", "comps"), ...) +\method{summary}{devMSM_comparisons}(object, type = "comps", ...) } \arguments{ -\item{obj}{initialized MSM object from \code{\link[=initMSM]{initMSM()}}} - \item{fit}{list of model outputs from \code{\link[=fitModel]{fitModel()}}} \item{hi_lo_cut}{list of two numbers indicating quantile values @@ -82,7 +79,7 @@ colors (n(epochs)+1) for plotting (default is "Dark2" palette)} \item{type}{Either "preds" or "comps" corresponding to the results of \code{\link[marginaleffects:predictions]{marginaleffects::avg_predictions()}} at low and high dosages or -\code{\link[marginaleffects:comparisons]{marginaleffects::comparisons()}} respectively} +\code{\link[marginaleffects:comparisons]{marginaleffects::avg_comparisons()}} respectively} } \value{ list containing two dataframes: \code{preds} with predictions from @@ -116,14 +113,13 @@ obj <- initMSM( tv_conf = c("B.1", "B.2", "B.3", "D.3") ) f <- createFormulas(obj, type = "short") -w <- createWeights(data = data, obj = obj, formulas = f) +w <- createWeights(data = data, formulas = f) fit <- fitModel( - data = data, obj = obj, weights = w, + data = data, weights = w, outcome = "D.3", model = "m0" ) comp <- compareHistories( - obj, fit = fit, hi_lo_cut = c(0.3, 0.6) ) @@ -133,7 +129,6 @@ summary(comp, "preds") summary(comp, "comps") comp2 <- compareHistories( - obj, fit = fit, reference = "l-l-l", comparison = c("h-h-h", "h-h-l") diff --git a/man/createFormulas.Rd b/man/createFormulas.Rd index 3b5cf810..a8f8ac3d 100644 --- a/man/createFormulas.Rd +++ b/man/createFormulas.Rd @@ -83,8 +83,8 @@ f <- createFormulas(obj, type = "short") print(f) # Update Formulas -w <- createWeights(data = data, obj = obj, formulas = f) -b <- assessBalance(data = data, obj = obj, weights = w) +w <- createWeights(data = data, formulas = f) +b <- assessBalance(data = data, weights = w) f <- createFormulas(obj, type = "update", bal_stats = b) print(f) diff --git a/man/createWeights.Rd b/man/createWeights.Rd index 88a12576..a15a3ead 100644 --- a/man/createWeights.Rd +++ b/man/createWeights.Rd @@ -4,13 +4,13 @@ \alias{createWeights} \alias{print.devMSM_weights} \alias{plot.devMSM_weights} +\alias{summary.devMSM_weights} \title{Creates IPTW balancing weights} \usage{ createWeights( data, - obj, formulas, - method = c("glm", "gbm", "bart", "super", "cbps", "ipt"), + method = "glm", verbose = FALSE, save.out = FALSE, ... @@ -19,13 +19,13 @@ createWeights( \method{print}{devMSM_weights}(x, i = 1, ...) \method{plot}{devMSM_weights}(x, i = 1, save.out = FALSE, ...) + +\method{summary}{devMSM_weights}(object, i = 1, ...) } \arguments{ \item{data}{data in wide format as: a data frame, list of imputed data frames, or \code{mids} object from the \code{mice} package} -\item{obj}{initialized MSM object from \code{\link[=initMSM]{initMSM()}}} - \item{formulas}{list of balancing formulas at each time point output from \code{\link[=createFormulas]{createFormulas()}}} \item{method}{(optional) character string of weightitMSM() balancing method @@ -40,12 +40,12 @@ To use a non-default file name, specify a character string with the file name. I There might be naming conflicts where two objects get saved to the same file. In these cases, users should specify a custom name. default is FALSE.} -\item{...}{ignored} +\item{\dots}{arguments passed to \code{\link[WeightIt:weightitMSM]{WeightIt::weightitMSM()}} or \code{\link[=summary.weightitMSM]{summary.weightitMSM()}}} -\item{x}{devMSM_weights object from \code{\link[=createWeights]{createWeights()}}} +\item{x, object}{devMSM_weights object from \code{createWeights()}} -\item{i}{For multiply imputed datset, \code{i} selects which imputation to print results for. -Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that.} +\item{i}{For multiply imputed datasets, \code{i} selects which imputation to print results for. +Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that. Ignored for non-imputed data.} } \value{ a list containing \code{\link[WeightIt:weightitMSM]{WeightIt::weightitMSM()}} output. It is the length @@ -77,25 +77,29 @@ obj <- initMSM( ) f <- createFormulas(obj, type = "short") -w <- createWeights(data = data, obj = obj, formulas = f) +w <- createWeights(data = data, formulas = f) print(w) plot(w) # Methods from `WeightIt::weightitMSM` -\dontshow{if (requireNamespace("CBPS", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -w <- createWeights(data = data, obj = obj, formulas = f, method = "cbps") -\dontshow{\}) # examplesIf} +w <- createWeights(data = data, formulas = f, + method = "glm") + +w <- createWeights(data = data, formulas = f, + method = "cbps") \dontshow{if (requireNamespace("gbm", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -w <- createWeights(data = data, obj = obj, formulas = f, method = "gbm") +w <- createWeights(data = data, formulas = f, + method = "gbm") \dontshow{\}) # examplesIf} \dontshow{if (requireNamespace("dbarts", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -w <- createWeights(data = data, obj = obj, formulas = f, method = "bart") +w <- createWeights(data = data, formulas = f, + method = "bart") \dontshow{\}) # examplesIf} \dontshow{if (requireNamespace("SuperLearner", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -w <- createWeights(data = data, obj = obj, formulas = f, method = "super") +w <- createWeights(data = data, formulas = f, + method = "super") \dontshow{\}) # examplesIf} } \seealso{ -\code{\link[WeightIt:weightitMSM]{WeightIt::weightitMSM()}}, -\url{https://ngreifer.github.io/WeightIt/reference/weightitMSM.html}; +\code{\link[WeightIt:weightitMSM]{WeightIt::weightitMSM()}} } diff --git a/man/devMSM_common_docs.Rd b/man/devMSM_common_docs.Rd deleted file mode 100644 index 64ae9a2e..00000000 --- a/man/devMSM_common_docs.Rd +++ /dev/null @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/devMSMs-package.R -\name{devMSM_common_docs} -\alias{devMSM_common_docs} -\title{Common documentation for devMSMs functions} -\usage{ -devMSM_common_docs( - data, - obj, - formulas, - weights, - fit, - bal_stats, - verbose, - save.out, - home_dir, - i, - t -) -} -\arguments{ -\item{data}{data in wide format as: a data frame, list of imputed data -frames, or \code{mids} object from the \code{mice} package} - -\item{obj}{initialized MSM object from \code{\link[=initMSM]{initMSM()}}} - -\item{formulas}{list of balancing formulas at each time point output from \code{\link[=createFormulas]{createFormulas()}}} - -\item{weights}{list of IPTW weights output from \code{\link[=createWeights]{createWeights()}}} - -\item{fit}{list of model outputs from \code{\link[=fitModel]{fitModel()}}} - -\item{bal_stats}{list of balance statistics from \code{\link[=assessBalance]{assessBalance()}}} - -\item{verbose}{(optional) TRUE or FALSE indicator for printing output to console. -default is FALSE.} - -\item{save.out}{(optional) Either logical or a character string. If \code{TRUE}, -it will output the result to a default file name within \code{home_dir} set in \code{initMSM()}. You can load the data with \code{x <- readRDS(file)}. -To use a non-default file name, specify a character string with the file name. It will save relative to \code{home_dir}. -There might be naming conflicts where two objects get saved to the same file. In these cases, users should specify a custom name. -default is FALSE.} - -\item{i}{For multiply imputed datset, \code{i} selects which imputation to print results for. -Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that.} - -\item{t}{Which exposure variable to use. Can either be an index from 1, ..., num exposures or -a string containing the exposure varaible name (e.g. \code{"A.3"}). With \code{t = TRUE}, all exposure -variables will be looped over.} -} -\description{ -Common documentation for devMSMs functions -} -\keyword{internal} diff --git a/man/dot-add_histories.Rd b/man/dot-add_histories.Rd deleted file mode 100644 index f5b36961..00000000 --- a/man/dot-add_histories.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.add_histories} -\alias{.add_histories} -\title{Add history labels and dose to table based on \code{epoch_vars}} -\usage{ -.add_histories(p, epoch_vars) -} -\arguments{ -\item{p}{table output from marginaleffects::avg_predictions() or hypotheses()} - -\item{epoch_vars}{variable names of exposure epoch (in time order)} -} -\value{ -table with histories labeled -} -\description{ -Add history labels and dose to table based on \code{epoch_vars} -} -\keyword{internal} diff --git a/man/dot-avg_imp_bal_stats.Rd b/man/dot-avg_imp_bal_stats.Rd deleted file mode 100644 index 2e0769c0..00000000 --- a/man/dot-avg_imp_bal_stats.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.avg_imp_bal_stats} -\alias{.avg_imp_bal_stats} -\title{Added by IS: averages balance stats across time points and recalculates balance: -returns one bal stat per covar} -\usage{ -.avg_imp_bal_stats(bal_stats) -} -\description{ -Added by IS: averages balance stats across time points and recalculates balance: -returns one bal stat per covar -} -\keyword{internal} diff --git a/man/dot-avg_imp_bal_stats_time.Rd b/man/dot-avg_imp_bal_stats_time.Rd deleted file mode 100644 index 433a93f1..00000000 --- a/man/dot-avg_imp_bal_stats_time.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.avg_imp_bal_stats_time} -\alias{.avg_imp_bal_stats_time} -\title{Added by IS: Averages balance stats across imputed datasets: list by time} -\usage{ -.avg_imp_bal_stats_time(bal_stats) -} -\description{ -Added by IS: Averages balance stats across imputed datasets: list by time -} -\keyword{internal} diff --git a/man/dot-characterize_exposure.Rd b/man/dot-characterize_exposure.Rd deleted file mode 100644 index 58fb4e1e..00000000 --- a/man/dot-characterize_exposure.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.characterize_exposure} -\alias{.characterize_exposure} -\title{Used in \code{assessBalance} to define history} -\usage{ -.characterize_exposure(mat, exposure_type) -} -\description{ -Used in \code{assessBalance} to define history -} -\keyword{internal} diff --git a/man/dot-create_hypotheses_mat.Rd b/man/dot-create_hypotheses_mat.Rd deleted file mode 100644 index e0a6ffa9..00000000 --- a/man/dot-create_hypotheses_mat.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.create_hypotheses_mat} -\alias{.create_hypotheses_mat} -\title{Create contrast map using comparison and reference} -\usage{ -.create_hypotheses_mat(histories, reference, comparison) -} -\arguments{ -\item{histories}{character vector (from preds$term corresponding to average predictions)} - -\item{reference}{character vector of exposure histories} - -\item{comparison}{character vector of exposure histories} -} -\description{ -Create contrast map using comparison and reference -} -\keyword{internal} diff --git a/man/dot-dose_from_history.Rd b/man/dot-dose_from_history.Rd deleted file mode 100644 index be859779..00000000 --- a/man/dot-dose_from_history.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.dose_from_history} -\alias{.dose_from_history} -\title{Calculate number of doses from history string (e.g. "l-l-l")} -\usage{ -.dose_from_history(history, dose_level = "h") -} -\description{ -Calculate number of doses from history string (e.g. "l-l-l") -} -\examples{ -library(devMSMs) -devMSMs:::.dose_from_history(c("l-l-l-h", "l-l-l-l"), dose_level = "h") -devMSMs:::.dose_from_history(c("l-l-l-h", "l-l-l-l"), dose_level = "l") - -} -\keyword{internal} diff --git a/man/dot-dose_from_history_contrast.Rd b/man/dot-dose_from_history_contrast.Rd deleted file mode 100644 index f9f5d6b7..00000000 --- a/man/dot-dose_from_history_contrast.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.dose_from_history_contrast} -\alias{.dose_from_history_contrast} -\title{Calculate number of doses from history string (e.g. "l-l-l")} -\usage{ -.dose_from_history_contrast(history, dose_level = "h") -} -\description{ -Calculate number of doses from history string (e.g. "l-l-l") -} -\examples{ -library(devMSMs) -devMSMs:::.dose_from_history_contrast(c("(h-h-h) - (l-l-l)"), dose_level = "h") -devMSMs:::.dose_from_history_contrast(c("(h-h-h) - (l-l-l)"), dose_level = "l") - -} -\keyword{internal} diff --git a/man/dot-extract_time_pts_from_vars.Rd b/man/dot-extract_time_pts_from_vars.Rd deleted file mode 100644 index a1ec25f2..00000000 --- a/man/dot-extract_time_pts_from_vars.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.extract_time_pts_from_vars} -\alias{.extract_time_pts_from_vars} -\title{Grabs trailing numbers after the last occurance of \code{sep} in \code{vars}} -\usage{ -.extract_time_pts_from_vars(vars, sep = "[\\\\._]") -} -\description{ -Grabs trailing numbers after the last occurance of \code{sep} in \code{vars} -} -\keyword{internal} diff --git a/man/dot-generate_epoch_exposures.Rd b/man/dot-generate_epoch_exposures.Rd deleted file mode 100644 index 7c6edbd9..00000000 --- a/man/dot-generate_epoch_exposures.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.generate_epoch_exposures} -\alias{.generate_epoch_exposures} -\title{Takes row means of eposure variables in the same epoch} -\usage{ -.generate_epoch_exposures(data, exposure, epoch, sep) -} -\description{ -Takes row means of eposure variables in the same epoch -} -\keyword{internal} diff --git a/man/dot-get_avg_predictions_variables.Rd b/man/dot-get_avg_predictions_variables.Rd deleted file mode 100644 index b7322d4c..00000000 --- a/man/dot-get_avg_predictions_variables.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.get_avg_predictions_variables} -\alias{.get_avg_predictions_variables} -\title{Grab values of epoch variables to evaluate in \code{marginaleffects::predictions}} -\usage{ -.get_avg_predictions_variables( - data, - epoch_vars, - exposure_type, - hi_lo_cut = NULL -) -} -\description{ -For continuous variables, grab quantiles of the epoch variables based on hi_lo_cut -For binary variables, use 0 and 1. -} -\keyword{internal} diff --git a/man/dot-get_epoch_var_names.Rd b/man/dot-get_epoch_var_names.Rd deleted file mode 100644 index aa4580ce..00000000 --- a/man/dot-get_epoch_var_names.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.get_epoch_var_names} -\alias{.get_epoch_var_names} -\title{Simple function to get the variable names associated with epochs} -\usage{ -.get_epoch_var_names(exposure, epoch, sep) -} -\description{ -Simple function to get the variable names associated with epochs -} -\keyword{internal} diff --git a/man/dot-get_history_values.Rd b/man/dot-get_history_values.Rd deleted file mode 100644 index 0c0f9010..00000000 --- a/man/dot-get_history_values.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.get_history_values} -\alias{.get_history_values} -\title{Finds custom reference values (currently unused)} -\usage{ -.get_history_values(epoch_d, exp_history) -} -\arguments{ -\item{epoch_d}{data frame of high and low values per exposure main effect} - -\item{exp_history}{sequence of "h" and/or "l" (e.g., "h-h-h")} -} -\value{ -exposure history values -} -\description{ -Finds custom reference values (currently unused) -} -\examples{ -epoch_d <- data.frame( - e = c("A.1", "A.2", "A.3"), - l = c(0, 0, 0), - h = c(1, 1, 1) -) -r <- devMSMs:::.get_history_values( - epoch_d = epoch_d, - exp_history = "l-l-l" -) -r <- devMSMs:::.get_history_values( - epoch_d = epoch_d, - exp_history = "h-h-h" -) - -} -\keyword{internal} diff --git a/man/dot-get_interaction_terms.Rd b/man/dot-get_interaction_terms.Rd deleted file mode 100644 index 6386ad4a..00000000 --- a/man/dot-get_interaction_terms.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.get_interaction_terms} -\alias{.get_interaction_terms} -\title{Return interactions up to order n of variables in \code{x}} -\usage{ -.get_interaction_terms(x, n = 2) -} -\arguments{ -\item{x}{character vector of variable names} - -\item{n}{order of interaction} -} -\description{ -Return interactions up to order n of variables in \code{x} -} -\keyword{internal} diff --git a/man/dot-remove_time_pts_from_vars.Rd b/man/dot-remove_time_pts_from_vars.Rd deleted file mode 100644 index 237f4a12..00000000 --- a/man/dot-remove_time_pts_from_vars.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.remove_time_pts_from_vars} -\alias{.remove_time_pts_from_vars} -\title{Gets prefix of variable by numbers after last occurance of \code{sep} and optionally deleting \code{sep}} -\usage{ -.remove_time_pts_from_vars(vars, sep = "[\\\\._]", keep_sep = FALSE) -} -\description{ -Gets prefix of variable by numbers after last occurance of \code{sep} and optionally deleting \code{sep} -} -\keyword{internal} diff --git a/man/dot-string_count.Rd b/man/dot-string_count.Rd deleted file mode 100644 index f33ad06f..00000000 --- a/man/dot-string_count.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.string_count} -\alias{.string_count} -\title{Base R rewrite of stringr::str_count(); pattern can only be length 1} -\usage{ -.string_count(string, pattern = "") -} -\description{ -Base R rewrite of stringr::str_count(); pattern can only be length 1 -} -\keyword{internal} diff --git a/man/fitModel.Rd b/man/fitModel.Rd index aa1f9824..c102e193 100644 --- a/man/fitModel.Rd +++ b/man/fitModel.Rd @@ -8,18 +8,17 @@ fitModel( data, obj, - weights, + weights = NULL, outcome, - model = c("m0", "m1", "m2", "m3"), + model = "m0", int_order = NA, covariates = NULL, - family = NULL, - link = NA, + family = gaussian(), verbose = FALSE, save.out = FALSE ) -\method{print}{devMSM_models}(x, i = 1, save.out = FALSE, ...) +\method{print}{devMSM_models}(x, i = NA, save.out = FALSE, ...) } \arguments{ \item{data}{data in wide format as: a data frame, list of imputed data @@ -46,9 +45,7 @@ interaction, required for interaction models ("m2", "m3")} \item{covariates}{list of characters reflecting variable names of covariates, required for covariate models ("m1", "m3")} -\item{family}{(optional) family function specification for \code{\link[WeightIt:glm_weightit]{WeightIt::glm_weightit()}} model} - -\item{link}{(optional) character link function specification for \code{\link[WeightIt:glm_weightit]{WeightIt::glm_weightit()}} model} +\item{family}{(optional) family function specification for \code{\link[WeightIt:glm_weightit]{WeightIt::glm_weightit()}} model.} \item{verbose}{(optional) TRUE or FALSE indicator for printing output to console. default is FALSE.} @@ -61,8 +58,8 @@ default is FALSE.} \item{x}{devMSM_models object from \code{fitModel}} -\item{i}{For multiply imputed datset, \code{i} selects which imputation to print results for. -Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that.} +\item{i}{For multiply imputed datasets, \code{i} selects which imputation to print results for. +Default is \code{i = 1}. With \code{i = TRUE}, all imputed datasets will be looped over. With \code{i = NULL}, will average over all imputed datasets and summarize that. Ignored for non-imputed data.} \item{...}{ignored} } @@ -95,30 +92,30 @@ obj <- initMSM( tv_conf = c("B.1", "B.2", "B.3", "D.3") ) f <- createFormulas(obj, type = "short") -w <- createWeights(data = data, obj = obj, formulas = f) +w <- createWeights(data = data, formulas = f) fit_m0 <- fitModel( - data = data, obj = obj, weights = w, + data = data, weights = w, outcome = "D.3", model = "m0" ) print(fit_m0) fit_m1 <- fitModel( - data = data, obj = obj, weights = w, + data = data, weights = w, outcome = "D.3", model = "m1", covariates = c("C") ) print(fit_m1) fit_m2 <- fitModel( - data = data, obj = obj, weights = w, + data = data, weights = w, outcome = "D.3", model = "m2", int_order = 2 ) print(fit_m2) fit_m3 <- fitModel( - data = data, obj = obj, weights = w, + data = data, weights = w, outcome = "D.3", model = "m3", int_order = 2, covariates = c("C") ) diff --git a/man/make_love_plot.Rd b/man/make_love_plot.Rd deleted file mode 100644 index e9f51b12..00000000 --- a/man/make_love_plot.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/make_love_plot.R -\name{make_love_plot} -\alias{make_love_plot} -\title{Create love plots showing balancing statistics} -\usage{ -make_love_plot( - obj, - balance_stats, - exposure_type = c("continuous", "binary"), - k = 0, - weight_method = NULL -) -} -\arguments{ -\item{balance_stats}{data frame of balance statistics} - -\item{exposure_type}{String either "continuous" or "binary"} - -\item{k}{imputation number} - -\item{weight_method}{name of weighting method (NULL for unweighted)} -} -\value{ -ggplot2 object -} -\description{ -Create love plots showing balancing statistics -} -\examples{ -print("tbd") - -} -\keyword{internal} diff --git a/man/perm2.Rd b/man/perm2.Rd deleted file mode 100644 index f4e5deec..00000000 --- a/man/perm2.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{perm2} -\alias{perm2} -\title{Adaptation of gtools::permutations(2, repeats.allowed = TRUE)} -\usage{ -perm2(r, v) -} -\description{ -Adaptation of gtools::permutations(2, repeats.allowed = TRUE) -} -\keyword{internal} diff --git a/man/print_eval_hist.Rd b/man/print_eval_hist.Rd deleted file mode 100644 index 0b6d3cc5..00000000 --- a/man/print_eval_hist.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print_eval_hist.R -\name{print_eval_hist} -\alias{print_eval_hist} -\title{Visualize distribution of sample across exposure histories} -\usage{ -print_eval_hist( - epoch_history, - epoch, - hi_lo_cut, - reference = NULL, - comparison = NULL -) -} -\arguments{ -\item{epoch_history}{character vector of length \code{nrow(data)} containing epochi histories for -each unit} - -\item{epoch}{character vector of epoch values} - -\item{hi_lo_cut}{list of two numbers indicating quantile values -that reflect high and low values, respectively, for continuous exposure -(default is median split)} - -\item{reference}{lists of one or more strings of "-"-separated "l" -and "h" values indicative of a reference exposure history to which to -compare comparison, required if comparison is supplied} - -\item{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 supplied} -} -\value{ -invisibly NULL -} -\description{ -Create customized, user-specified exposure histories and tables displaying -sample distribution across them for user inspection. -} -\keyword{internal} diff --git a/man/trimWeights.Rd b/man/trimWeights.Rd index 0079b7f9..9a7241ef 100644 --- a/man/trimWeights.Rd +++ b/man/trimWeights.Rd @@ -4,18 +4,9 @@ \alias{trimWeights} \title{Trim IPTW balancing weights, if needed} \usage{ -trimWeights( - obj, - weights, - at = 0, - lower = FALSE, - verbose = FALSE, - save.out = FALSE -) +trimWeights(weights, at = 0, lower = FALSE, verbose = FALSE, save.out = FALSE) } \arguments{ -\item{obj}{initialized MSM object from \code{\link[=initMSM]{initMSM()}}} - \item{weights}{list of IPTW weights output from \code{\link[=createWeights]{createWeights()}}} \item{at}{\code{numeric}; either the quantile of the weights above which @@ -65,12 +56,12 @@ obj <- initMSM( ) f <- createFormulas(obj, type = "short") -w <- createWeights(data = data, obj = obj, formulas = f) -tw <- trimWeights(obj, w) +w <- createWeights(data = data, formulas = f) +tw <- trimWeights(w, at = 0.975) print(tw) plot(tw) -trimWeights(obj, w, at = 0.975, lower = TRUE) +trimWeights(w, at = 0.975, lower = TRUE) } \seealso{