Skip to content

Commit

Permalink
Fixed gcomp_stan() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Dec 4, 2023
1 parent 299c0e7 commit c25002a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
18 changes: 9 additions & 9 deletions R/IPD_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ IPD_stats.default <- function() {
#' using bootstrapping
#'
#' @param strategy
#' @param ipd
#' @param ald
#' @template args-ipd
#' @template args-ald
#'
#' @export
#'
Expand All @@ -174,8 +174,8 @@ IPD_stats.maic <- function(strategy,
#' IPD_stats.stc
#'
#' @param strategy
#' @param ipd
#' @param ald
#' @template args-ipd
#' @template args-ald
#' @export
#'
IPD_stats.stc <- function(strategy,
Expand All @@ -196,8 +196,8 @@ IPD_stats.stc <- function(strategy,
#' IPD_stats.gcomp_ml
#'
#' @param strategy
#' @param ipd
#' @param ald
#' @template args-ipd
#' @template args-ald
#'
#' @return
#' @export
Expand All @@ -220,8 +220,8 @@ IPD_stats.gcomp_ml <- function(strategy,
#' IPD_stats.gcomp_stan
#'
#' @param strategy
#' @param ipd
#' @param ald
#' @template args-ipd
#' @template args-ald
#'
#' @return
#' @export
Expand All @@ -230,7 +230,7 @@ IPD_stats.gcomp_stan <- function(strategy,
ipd, ald) {

ppv <- gcomp_stan(formula = strategy$formula,
dat = ipd)
ipd = ipd, ald = ald)

# compute marginal log-odds ratio for A vs C for each MCMC sample
# by transforming from probability to linear predictor scale
Expand Down
9 changes: 3 additions & 6 deletions R/gcomp_stan.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#' G-computation using Stan
#'
#' @param formula
#' @param ipd
#' @param ald
#' @template args-ipd
#' @template args-ald
#'
#' @return
#' @export
Expand All @@ -15,9 +15,7 @@ gcomp_stan <- function(formula = as.formula("y ~ X3 + X4 + trt*X1 + trt*X2"),

# remove treatment
cov_names <- cov_names[cov_names != treat_names]

n_covariates <- length(covariate_names)

n_covariates <- length(cov_names)
rho <- cor(ipd[, cov_names])

# covariate simulation for BC trial using copula package
Expand All @@ -40,7 +38,6 @@ gcomp_stan <- function(formula = as.formula("y ~ X3 + X4 + trt*X1 + trt*X2"),
# simulated BC pseudo-population of size 1000
x_star <- as.data.frame(rMvdc(1000, mvd))

browser()
colnames(x_star) <- cov_names

# outcome logistic regression fitted to IPD using MCMC (Stan)
Expand Down
1 change: 1 addition & 0 deletions man-roxygen/args-ald.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#' @param ald Aggregate-level data
1 change: 1 addition & 0 deletions man-roxygen/args-ipd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#' @param ipd Individual-level data
10 changes: 6 additions & 4 deletions man/gcomp_stan.Rd

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

0 comments on commit c25002a

Please sign in to comment.