Calculate the model parameters b0 and b1 that provide a given target power for testing for an overall treatment effect and an interaction effect (under the true model). The calculation is performed conditional on a given data set of covariates and treatment indicator. It is assumed that the treatment indicator is independent of the columns in X). The power of the overall test and the interaction test will depend on the actual observed covariates. To make calculations independent of the actual observed covariates (to focus on the super-population) it is suggested to simulate a large number of covariates (e.g. 100 times larger sample size than one would be interested in), based on this one can calculate an estimate of the covariance matrix of the estimates. To obtain a covariance matrix estimate for the sample size one is interested in one can then scale up the covariance matrix estimate (e.g. by 100-fold in the example above). Note that there may not be any solution or a unique solution, in case of non-convergence (which particularly happens for the binary endpoint) it sometimes helps to modify start and optim_method arguments.

get_b(
  X,
  scal,
  prog,
  pred,
  trt,
  type,
  power = c(0.9, 0.8),
  alpha = c(0.025, 0.1),
  start = c(0, 0),
  sign_better = 1,
  sigma_error,
  theta,
  lambda0,
  cens_time,
  t_mile,
  optim_method = "Nelder-Mead"
)

Arguments

X

Matrix with all covariates

scal

Scaling parameter for the covariance matrix

prog

Character variable giving expression for prognostic effects (defined in terms of names in the X matrix)

pred

Character variable giving expression for predictive effects (defined in terms of names in the X matrix)

trt

Treatment effect indicator (same length as number of rows in X).

type

type of data "continuous", "binary", "count" and "survival" are allowed here, but calculations are only implemented for "continuous" and "binary".

power

Vector of length 2, specifying the target power for the overall and the interaction test

alpha

Vector of length 2, specifying the desired type 1 error for the overall and the interaction test. The overall test is performed as a one-sided test (see also argument sign_better). The interaction test is performed as a two-sided test.

start

Vector of length 2: Starting values for the parameter b.

sign_better

1 if larger response is better, -1 is smaller response is better (used in power calculation for the overall test only)

sigma_error

Residual variance assumed for type = "continuous"

theta

overdispersion paramter for type = count". It is consistent with MASS::glm.nb and the (dprq)nbinom functions in R with the "size" parameter equal to theta. In this parameterization the negative binomial distribution converges to the Poisson distribution for theta goes to infinity.

lambda0

Intercept of exponential regression (on non-log scale)

cens_time

Function to generate the censoring time, only needed for data_type = "survival"

t_mile

Time point for comparing survival probabilities for overall test for treatment effect

optim_method

method argument in the optimization see ?optim

Value

Vector of two model parameters b0 and b1

Examples

scal <- 100
X <- generate_X_dist(n = 500 * scal, p = 30, rho = 0.5)
trt <- generate_trt(n = 500 * scal, p_trt = 0.5)
prog <- "0.5*((X1=='Y')+X11)"
pred <- "X11>0.5"
get_b(X, scal, prog, pred, trt,
  type = "continuous",
  power = c(0.9, 0.9), alpha = c(0.025, 0.1),
  start = c(0, 0), sigma_error = 1
)
#> [1] 0.2038864 0.4571681
#> attr(,"power_results")
#> [1] 0.9 0.9
get_b(X, scal, prog, pred, trt,
  type = "binary",
  power = c(0.9, 0.9), alpha = c(0.025, 0.1),
  start = c(0, 0)
)
#> [1] 0.3866068 1.4969530
#> attr(,"power_results")
#> [1] 0.9 0.9