Skip to content

Commit

Permalink
Initial CRAN release.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbannick committed May 13, 2024
1 parent 17f0f35 commit 7afa350
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 54 deletions.
6 changes: 4 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
^.*\.Rproj$
RobinCar.Rproj
*.tar.gz*
docs/
doc/
^\.Rproj\.user$
^LICENSE\.md$
^_pkgdown\.yml$
^docs$
^pkgdown$
^doc$
^Meta$
^\.github$
^CITATION.cff
^doc$
^vignettes/articles$
^CRAN-SUBMISSION$
^cran-comments\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ RobinCar.Rproj
inst/doc
/Meta/
..Rcheck
/doc/
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Authors@R: c(
person("Faith", "Bian", role="aut")
)
Description: Performs robust estimation and inference when using covariate adjustment and/or covariate-adaptive randomization in randomized controlled trials.
Ting Ye, Jun Shao, Yanyao Yi, Qinyuan Zhao (2023) <doi:10.1080/01621459.2022.2049278>
Ting Ye, Marlena Bannick, Yanyao Yi, Jun Shao (2023) <doi:10.1080/24754269.2023.2205802>
Ting Ye, Jun Shao, Yanyao Yi (2023) <doi:10.1093/biomet/asad045>
Marlena Bannick, Jun Shao, Jingyi Liu, Yu Du, Yanyao Yi, Ting Ye (2024) <arXiv:2306.10213>
Ting Ye, Jun Shao, Yanyao Yi, Qinyuan Zhao (2023) <doi:10.1080/01621459.2022.2049278>.
Ting Ye, Marlena Bannick, Yanyao Yi, Jun Shao (2023) <doi:10.1080/24754269.2023.2205802>.
Ting Ye, Jun Shao, Yanyao Yi (2023) <doi:10.1093/biomet/asad045>.
Marlena Bannick, Jun Shao, Jingyi Liu, Yu Du, Yanyao Yi, Ting Ye (2024) <doi:10.48550/arXiv.2306.10213>.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
10 changes: 5 additions & 5 deletions R/robincar-SL.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#' @param covariate_to_include_strata Whether to include car_strata variables in covariate adjustment. Defaults to F for ANOVA and ANCOVA; defaults to T for ANHECOVA. User may override by passing in this argument.
#' @param contrast_h An optional function to specify a desired contrast
#' @param contrast_dh An optional jacobian function for the contrast (otherwise use numerical derivative)
#' @param SL_libraries Vector of super-learner libraries to use for the covariate adjustment (see \link{SuperLearner::listWrappers})
#' @param SL_learners Optional list of super-learner "learners" to use for the covariate adjustment (see \link{SuperLearner::create.Learner})
#' @param SL_libraries Vector of super-learner libraries to use for the covariate adjustment (see \link[SuperLearner:listWrappers]{SuperLearner::listWrappers})
#' @param SL_learners Optional list of super-learner "learners" to use for the covariate adjustment (see \link[SuperLearner:create.Learner]{SuperLearner::create.Learner())}
#' @param k_split Number of splits to use in cross-fitting
#' @param g_accuracy Level of accuracy to check prediction un-biasedness (in digits).
#'
Expand Down Expand Up @@ -69,8 +69,8 @@
#'
#' sl.mod$result
#'
#' @returns See value of \link{RobinCar::robincar_glm}, but the working model for \eqn{\hat{\mu}(X_i)} is based on the \link{AIPW:AIPW} package that uses specified SuperLearner libraries and cross-fitting.
#' Also, `mod` attribute is an object of class \link{AIPW::AIPW}.
#' @returns See value of \link[RobinCar:robincar_glm]{RobinCar::robincar_glm}, but the working model for \eqn{\hat{\mu}(X_i)} is based on the \link{AIPW} package that uses specified SuperLearner libraries and cross-fitting.
#' Also, `mod` attribute is an object of class \link[AIPW:AIPW]{AIPW::AIPW}.
robincar_SL <- function(df,
treat_col, response_col, car_strata_cols=NULL, covariate_cols=NULL,
car_scheme="simple",
Expand Down Expand Up @@ -145,7 +145,7 @@ robincar_SL <- function(df,
#' @inheritParams robincar_SL
#' @export
#'
#' @returns See value of \link{RobinCar::robincar_SL}.
#' @returns See value of \link[RobinCar:robincar_SL]{RobinCar::robincar_SL}.
#' Attributes `mods` and `mu_as` are lists of `mod` and `mu_a` attributes, respectively, for each replicate of `robincar_SL` used in the median.
robincar_SL_median <- function(n_times, seed, df,
treat_col, response_col,
Expand Down
4 changes: 2 additions & 2 deletions R/robincar-calibrate.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Perform linear or joint calibration
#'
#' Uses linear or joint calibration to "calibrate" the estimates from a linear or GLM-type adjustment.
#' Linear calibration fits a linear model with treatment and with the predicted \eqn{\hat{\mu}_a(X_i)} as constructed covariates;
#' Linear calibration fits a linear model with treatment (and treatment-by-covariate interactions) and with the predicted \eqn{\hat{\bm \mu}(X_i) = (\hat{\mu}_1(X_i), \dots, \hat{\mu}_K(X_i))} as constructed covariates where \eqn{K} is the number of treatment groups;
#' joint calibration also includes \eqn{Z_i} the strata variables as covariates.
#'
#' @param result A GLMModelResult
Expand All @@ -13,7 +13,7 @@
#' the original dataset that robincar_glm was called on.
#' @export
#'
#' @returns A result object that has the same structure as \link{RobinCar::robincar_glm}, with the argument `result` included as "original" in the list.
#' @returns A result object that has the same structure as \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}, with the argument `result` included as "original" in the list.
robincar_calibrate <- function(result, joint=FALSE,
add_x=NULL){

Expand Down
4 changes: 2 additions & 2 deletions R/robincar-contrast.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contrast <- function(settings, treat, est, varcov){

#' Estimate a treatment contrast
#'
#' Estimate a treatment contrast using the result of \link{RobinCar::robincar_linear}, \link{RobinCar::robincar_glm}, or \link{RobinCar::robincar_SL} using
#' Estimate a treatment contrast using the result of \link[RobinCar:robincar_linear]{RobinCar::robincar_linear()}, \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}, or \link[RobinCar:robincar_SL]{RobinCar::robincar_SL()} using
#' the delta method.
#'
#' @param result A LinModelResult or GLMModelResult
Expand All @@ -108,7 +108,7 @@ contrast <- function(settings, treat, est, varcov){
#'
#' @returns A contrast object which has the following attributes:
#'
#' \item{result}{A \link{dplyr::tibble} with the label of the treatment contrast (e.g., 1 vs. 0), the estimate of the treatment contrast, estimated SE, and p-value based on a z-test with estimate and SE.}
#' \item{result}{A \link[dplyr:tibble]{dplyr::tibble()} with the label of the treatment contrast (e.g., 1 vs. 0), the estimate of the treatment contrast, estimated SE, and p-value based on a z-test with estimate and SE.}
#' \item{varcov}{The variance-covariance matrix for the treatment contrast estimates.}
#' \item{settings}{List of model settings used for the contrast.}
#'
Expand Down
10 changes: 5 additions & 5 deletions R/robincar-glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @param covariate_to_include_strata Whether to include car_strata variables in covariate adjustment. Defaults to F for homogeneous; defaults to T for heterogeneous. User may override by passing in this argument.
#' @param contrast_h An optional function to specify a desired contrast
#' @param contrast_dh An optional jacobian function for the contrast (otherwise use numerical derivative)
#' @param g_family Family that would be supplied to \link{stats::glm}, e.g., binomial. If no link specified, will use default link, like behavior in glm.
#' @param g_family Family that would be supplied to \link[stats:glm]{glm()}, e.g., binomial. If no link specified, will use default link, like behavior in glm.
#' If you wish to use a negative binomial working model with an unknown dispersion parameter, then use `g_family="nb"`.
#' @param g_accuracy Level of accuracy to check prediction un-biasedness.
#' @param formula An optional formula to use for adjustment specified using as.formula("..."). This overrides car_strata_cols and covariate_cols.
Expand All @@ -34,16 +34,16 @@
#'
#' @returns If `contrast_h` argument is used, outputs a `main` and a `contrast` object. The `main` object has the following structure:
#'
#' \item{result}{A \link{dplyr::tibble} with the treatment label, treatment mean estimate using AIPW, estimated SE, and p-value based on a z-test with estimate and SE.}
#' \item{result}{A \link[dplyr:tibble]{dplyr::tibble()} with the treatment label, treatment mean estimate using AIPW, estimated SE, and p-value based on a z-test with estimate and SE.}
#' \item{varcov}{The variance-covariance matrix for the treatment mean estimates.}
#' \item{settings}{List of model settings used in covariate adjustment.}
#' \item{original_df}{The original dataset provided by the user.}
#' \item{mod}{The fit from the \link{stats::glm} working model used for covariate adjustment.}
#' \item{mod}{The fit from the \link[stats:glm]{glm()} working model used for covariate adjustment.}
#' \item{mu_a}{Predicted potential outcomes for each treatment category (columns) and individual (rows). These are the \eqn{\hat{\mu}_a}}.
#' \item{g.estimate}{The G-computation estimate based only on \eqn{\frac{1}{n} \sum_{i=1}^{n} \hat{\mu}_a(X_i)}. This is equivalent to the AIPW estimate when a canonical link function is used.}
#' \item{data}{Attributes about the dataset.}
#'
#' The `contrast` object has a structure that is documented in \link{RobinCar::robincar_contrast}.
#' The `contrast` object has a structure that is documented in \link[RobinCar:robincar_contrast]{RobinCar::robincar_contrast()}.
robincar_glm <- function(df,
treat_col, response_col, car_strata_cols=NULL, covariate_cols=NULL,
car_scheme="simple", adj_method="heterogeneous", # vcovHC="HC0",
Expand Down Expand Up @@ -112,7 +112,7 @@ robincar_glm <- function(df,
#' @param g_accuracy Level of accuracy to check prediction un-biasedness.
#' @export
#'
#' @returns See value of \link{RobinCar::robincar_glm}. This function is a wrapper for \link{RobinCar::robincar_glm}.
#' @returns See value of \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}. This function is a wrapper for \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}.
robincar_glm2 <- function(df,
treat_col, response_col,
formula=NULL, car_strata_cols=NULL,
Expand Down
6 changes: 3 additions & 3 deletions R/robincar-linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @param contrast_dh An optional jacobian function for the contrast (otherwise use numerical derivative)
#' @export
#'
#' @returns See value of \link{RobinCar::robincar_glm}. This function is a wrapper for \link{RobinCar::robincar_glm}, using an identity link for the glm.
#' @returns See value of \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}, this function is a wrapper using an identity link for the glm.
robincar_linear <- function(df,
treat_col, response_col, car_strata_cols=NULL, covariate_cols=NULL,
car_scheme="simple", adj_method="ANOVA",
Expand Down Expand Up @@ -56,7 +56,7 @@ robincar_linear <- function(df,
#' Estimate treatment-group-specific response means and (optionally)
#' treatment group contrasts using a linear working model for continuous outcomes.
#'
#' Note the difference between \link{RobinCar::robincar_linear} and \link{RobinCar::robincar_linear2} with regards to their `covariate_cols` argument.
#' Note the difference between \link[RobinCar:robincar_linear]{RobinCar::robincar_linear()} and \link[RobinCar:robincar_linear2]{RobinCar::robincar_linear2()} with regards to their `covariate_cols` argument.
#'
#' @param df A data.frame with the required columns
#' @param treat_col Name of column in df with treatment variable
Expand All @@ -69,7 +69,7 @@ robincar_linear <- function(df,
#' @param contrast_dh An optional jacobian function for the contrast (otherwise use numerical derivative)
#' @export
#'
#' @returns See value of \link{RobinCar::robincar_linear}. This function is a wrapper for \link{RobinCar::robincar_linear}.
#' @returns See value of \link[RobinCar:robincar_linear]{RobinCar::robincar_linear()}, this function is a wrapper.
robincar_linear2 <- function(df,
treat_col, response_col, car_strata_cols=NULL, covariate_cols=NULL,
car_scheme="simple", adj_method="ANOVA",
Expand Down
2 changes: 1 addition & 1 deletion R/robincar-tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#'
#' @export
#'
#' @returns For adjustment method "CL" or "CSL", see value of \link{RobinCar::robincar_logrank}; for adjustment method "coxscore" see value of \link{RobinCar::robincar_coxscore}.
#' @returns For adjustment method "CL" or "CSL", see value of \link[RobinCar:robincar_linear]{RobinCar::robincar_logrank()}; for adjustment method "coxscore" see value of \link[RobinCar:robincar_coxscore]{RobinCar::robincar_coxscore()}.
robincar_tte <- function(df,
treat_col, response_col, event_col,
adj_method,
Expand Down
10 changes: 5 additions & 5 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @export
#'
#' @returns Prints the treatment mean estimates (and variances) based on a linear working model,
#' along with the settings used. See \link{RobinCar::robincar_linear}.
#' along with the settings used. See \link[RobinCar:robincar_linear]{RobinCar::robincar_linear()}.
print.LinModelResult <- function(x, ...){
descript(x)
cat("\n\n")
Expand All @@ -22,7 +22,7 @@ print.LinModelResult <- function(x, ...){
#' @export
#'
#' @returns Prints the treatment mean estimates (and variances) based on a GLM working model,
#' along with the settings used. See \link{RobinCar::robincar_glm}.
#' along with the settings used. See \link[RobinCar:robincar_glm]{RobinCar::robincar_glm()}.
print.GLMModelResult <- function(x, ...){
descript(x)
cat("\n\n")
Expand All @@ -39,7 +39,7 @@ print.GLMModelResult <- function(x, ...){
#' @export
#'
#' @returns Prints estimates (and variances) of treatment contrasts based on a linear or GLM working model,
#' along with the settings used. See \link{RobinCar::robincar_contrast}
#' along with the settings used. See \link[RobinCar:robincar_contrast]{RobinCar::robincar_contrast()}
print.ContrastResult <- function(x, ...){
if("DIFF" %in% class(x$settings)){
c_type <- "linear contrast"
Expand Down Expand Up @@ -68,7 +68,7 @@ print.ContrastResult <- function(x, ...){
#'
#' @returns Prints results of time-to-event covariate adjusted analyses including covariate-adjusted (stratified) logrank,
#' robust Cox score, and covariate-adjusted hazard ratio. Prints summary statistics about number of observations and events, possibly by strata,
#' and the test statistics and/or estimates, and p-values. See \link{RobinCar::robincar_tte} and \link{RobinCar::robincar_covhr}.
#' and the test statistics and/or estimates, and p-values. See \link[RobinCar:robincar_tte]{RobinCar::robincar_tte()} and \link[RobinCar:robincar_covhr]{RobinCar::robincar_covhr()}.
print.TTEResult <- function(x, ...){

if(!is.null(x$data$covariate)){
Expand Down Expand Up @@ -193,7 +193,7 @@ print.TTEResult <- function(x, ...){
#' @export
#'
#' @returns Prints the treatment mean estimates (and variances) based on a calibration on top of a
#' GLM working model, along with the settings used. See \link{RobinCar::robincar_calibrate}.
#' GLM working model, along with the settings used. See \link[RobinCar:robincar_calibrate]{RobinCar::robincar_calibrate()}.
print.CalibrationResult <- function(x, ...){
if(x$joint){
type <- "Joint calibration"
Expand Down
2 changes: 1 addition & 1 deletion man/print.CalibrationResult.Rd

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

2 changes: 1 addition & 1 deletion man/print.ContrastResult.Rd

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

2 changes: 1 addition & 1 deletion man/print.GLMModelResult.Rd

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

2 changes: 1 addition & 1 deletion man/print.LinModelResult.Rd

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

2 changes: 1 addition & 1 deletion man/print.TTEResult.Rd

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

8 changes: 4 additions & 4 deletions man/robincar_SL.Rd

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

6 changes: 3 additions & 3 deletions man/robincar_SL_median.Rd

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

Loading

0 comments on commit 7afa350

Please sign in to comment.