get_b0.RdCalculate the model parameters b0 (for a given b1) that provides a given target power for testing for an overall treatment effect. The calculation is performed conditional on a given data set of covariates and treatment indicator. The power of the overall test depends 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 determine 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).
get_b0(
X,
scal,
prog,
pred,
trt,
b1,
type,
power = 0.9,
alpha = 0.025,
sign_better = 1,
sigma_error,
theta,
lambda0,
cens_time,
t_mile,
interval = c(-5, 5)
)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).
The parameter b1 (calculation of b0 is for a given b1)
type of data "continuous", "binary", "count" and "survival" are allowed here, but calculations are only implemented for "continuous" and "binary" currently.
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.
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
Interval to search for b0 handed over to uniroot
Vector of model parameter b0
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_b0(X, scal, prog, pred, trt,
b1 = 0.5, type = "continuous",
power = 0.9, alpha = 0.025, interval = c(-2, 2), sigma_error = 1
)
#> [1] 0.1913504
#> attr(,"power_results")
#> [1] 0.899987
get_b0(X, scal, prog, pred, trt,
b1 = 0.5, type = "binary",
power = 0.9, alpha = 0.025, interval = c(-2, 2)
)
#> [1] 0.5320286
#> attr(,"power_results")
#> [1] 0.9000235