get_b.RdCalculate 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.
Matrix with all covariates
Scaling parameter for the covariance matrix
Character variable giving expression for prognostic effects (defined in terms of names in the X matrix)
Character variable giving expression for predictive effects (defined in terms of names in the X matrix)
Treatment effect indicator (same length as number of rows in X).
type of data "continuous", "binary", "count" and "survival" are allowed here, but calculations are only implemented for "continuous" and "binary".
Vector of length 2, specifying the target power for the overall and the interaction test
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.
Vector of length 2: Starting values for the parameter b.
1 if larger response is better, -1 is smaller response is better (used in power calculation for the overall test only)
Residual variance assumed for type = "continuous"
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.
Intercept of exponential regression (on non-log scale)
Function to generate the censoring time, only needed for data_type = "survival"
Time point for comparing survival probabilities for overall test for treatment effect
method argument in the optimization see ?optim
Vector of two model parameters b0 and b1
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