From 7580fdbb3f186d09c9f40eb3d1d549d2272fe895 Mon Sep 17 00:00:00 2001 From: Dr Nathan Green Date: Mon, 2 Sep 2024 11:50:16 +0100 Subject: [PATCH] should have fixed R checks --- DESCRIPTION | 6 +++--- R/gen_data.R | 18 +++++++++++------- R/print.R | 22 ++++++++++++---------- R/strategy_.R | 1 - outstandR.Rproj | 2 +- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e5f9159..56ffbd7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,8 +12,8 @@ Authors@R: c( comment = c(ORCID = "0000-0002-7263-4251"))) Description: Model-based standardisation with several different computation approaches. - See Remiro‐Azócar A, Heath A, Baio G (2022). Parametric G‐computation for compatible - indirect treatment comparisons with limited individual patient data. + See Remiro‐Azócar A, Heath A, Baio G (2022. Parametric G‐computation for compatible + indirect treatment comparisons with limited individual patient data, Res. Synth. Methods, 1–31. ISSN 1759-2879, . License: GPL (>= 3) Encoding: UTF-8 @@ -22,6 +22,7 @@ RoxygenNote: 7.3.2 Imports: boot, copula, + MASS, rstanarm, Rdpack (>= 0.7) Suggests: @@ -31,7 +32,6 @@ Suggests: gridExtra, here, knitr, - MASS, parallel, purrr, rmarkdown, diff --git a/R/gen_data.R b/R/gen_data.R index a88ffa3..b902c3f 100644 --- a/R/gen_data.R +++ b/R/gen_data.R @@ -18,6 +18,7 @@ #' #' @examples #' +#' \dontrun{ #' x <- gen_data( #' N = 100, #' b_trt = log(0.17), @@ -31,16 +32,18 @@ #' allocation = 2/3) #' #' head(x) -#' +#' } gen_data <- function(N, b_trt, b_X, b_EM, b_0, meanX, sdX, event_rate, corX, allocation) { # 4 baseline covariates - rho <- matrix(corX, nrow=4, ncol=4) # set correlation matrix - diag(rho) <- rep(1, 4) + n_c <- 4 + + rho <- matrix(corX, nrow=n_c, ncol=n_c) # set correlation matrix + diag(rho) <- rep(1, n_c) N_active <- round(N*allocation) # number of patients under active treatment N_control <- N - N_active # number of patients under control - sd.vec <- rep(sdX, 4) # vector of standard deviations + sd.vec <- rep(sdX, n_c) # vector of standard deviations cov.mat <- cor2cov(rho, sd.vec) # covariance matrix @@ -49,21 +52,22 @@ gen_data <- function(N, b_trt, b_X, b_EM, b_0, X_active <- as.data.frame( MASS::mvrnorm(n = N_active, - mu = rep(meanX, 4), + mu = rep(meanX, n_c), Sigma = cov.mat)) # patients under control treatment X_control <- as.data.frame( MASS::mvrnorm(n = N_control, - mu = rep(meanX, 4), + mu = rep(meanX, n_c), Sigma = cov.mat)) # all patients X <- rbind(X_active, X_control) colnames(X) <- c("X1", "X2", "X3", "X4") # treatment assignment (1: active; 0: control) - trt <- c(rep(1,N_active), rep(0,N_control)) + trt <- c(rep(1, N_active), + rep(0, N_control)) # generate binary outcomes using logistic regression # linear predictor diff --git a/R/print.R b/R/print.R index e3a9aea..e0c2c0d 100644 --- a/R/print.R +++ b/R/print.R @@ -1,14 +1,16 @@ #' @export print.outstandR <- function(x, newline = TRUE) { - - cat("\nContrasts:", x$contrasts, "\n") - cat("\nVariances:", x$contrasts_variances, "\n") - cat("\nConfidence intervals:", x$contrasts_ci, "\n") - - if (newline) { - cat("\n") - } - - invisible(x) + x + + #TODO: + # cat("\nContrasts:", x$contrasts, "\n") + # cat("\nVariances:", x$contrasts_variances, "\n") + # cat("\nConfidence intervals:", x$contrasts_ci, "\n") + # + # if (newline) { + # cat("\n") + # } + # + # invisible(x) } diff --git a/R/strategy_.R b/R/strategy_.R index a3ed344..4707584 100644 --- a/R/strategy_.R +++ b/R/strategy_.R @@ -22,7 +22,6 @@ #' \eqn{t} is equal to the odds of being enrolled in the _AC_ trial vs the _AB_ trial. #' #' @param R The number of resamples used for the non-parametric bootstrap -#' @template args-ald #' @return `maic` class object #' #' @importFrom utils modifyList diff --git a/outstandR.Rproj b/outstandR.Rproj index 6843888..9f96499 100644 --- a/outstandR.Rproj +++ b/outstandR.Rproj @@ -15,4 +15,4 @@ LaTeX: pdfLaTeX BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace,vignette +PackageRoxygenize: rd,collate,namespace