print.bayes_ctd_array: Print Data from Two Arm Bayesian Clinical Trial Simulation.

Description Usage Arguments Details Value Examples

View source: R/BayesCTDesigncode.R

Description

print.bayes_ctd_array() takes an S3 object of class bayes_ctd_array, and prints a two dimensional slice from the data generated by a clinical trial simulation using historic_sim() or simple_sim().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'bayes_ctd_array'
print(
  x = NULL,
  measure = "power",
  tab_type = "WX|YZ",
  subj_per_arm_val = NULL,
  a0_val = NULL,
  effect_val = NULL,
  rand_control_diff_val = NULL,
  print_chg_warn = 1,
  ...
)

Arguments

x

Name of object of class bayes_ctd_array containing data from clinical trial simulation.

measure

Must be equal to power, est, var, bias, or mse. Default is power. Case does not matter.

tab_type

A character string that must equal WX|YZ, WY|XZ, WZ|XY, XY|WZ, XZ|WY, YZ|WX, ZX|WY, XW|YZ, YW|XZ, YX|WZ, ZW|XY, ZX|WY, ZY|WX when x is generated by historic_sim(). Default is WX|YZ. When x is generated by simple_sim(), tab_type is ignored.

subj_per_arm_val

Must be non-missing, if x is generated by historic_sim() and sample size is being held constant. If x is generated by historic_sim() and sample size is being held constant, subj_per_arm_val must equal a value submitted to historic_sim() within the subj_per_arm parameter. When x is generated by simple_sim(), subj_per_arm_val is ignored.

a0_val

Must be non-missing, if x is generated by historic_sim() and a0, the power prior parameter, is being held constant. If x is generated by historic_sim() and a0 is being held constant, a0_val must equal a value submitted to historic_sim() within the a0_vals parameter. When x is generated by simple_sim(), a0_val is ignored.

effect_val

Must be non-missing, if x is generated by historic_sim() and effect is being held constant. If x is generated by historic_sim() and effect is being held constant, effect_val must equal a value submitted to historic_sim() within the effect_vals parameter. When x is generated by simple_sim(), effect_val is ignored.

rand_control_diff_val

Must be non-missing, if x is generated by historic_sim() and differences between randomized and historical controls are being held constant. If x is generated by historic_sim() and control differences are being held constant, rand_control_diff_val must equal a value submitted to historic_sim() within the rand_control_diff parameter. When x is generated by simple_sim(), rand_control_diff_val is ignored.

print_chg_warn

A parameter not used by the user, but is used by plot() to ensure warnings are not printed twice.

...

further arguments passed to or from other methods.

Details

If the object of class bayes_ctd_array is created by historic_sim(), then the function print() allows the user to print user-specified 1- and 2- dimensional slices of the simulation results based on slicing code described below. If the object of class bayes_ctd_array is created by simple_sim(), a basic table of characteristic by sample size and effect is created.

If the object of class bayes_ctd_array is created by simple_sim(), then all four trial characteristics (subj_per_arm_val, a0_vals, effect_val, and rand_control_diff_val) can be ignored, as can the parameter defining what type of table to print, tab_type. A call to print() will require the user to specify a measure (power, est, var, bias, or mse).

If the object of class bayes_ctd_array is created by historic_sim(), a call to print() will require the user to specify a measure (power, est, var, bias, or mse) and may require the user to specify a table type. A table type, tab_type, will be required if 3 of the 4 trial characteristics are equal to a vector of 2 or more values. The table type specification uses the letters W, X, Y, and Z. The letter W represents the subject per arm dimension. The letter X represents the a0 dimension. The letter Y represents the effect dimension. The letter Z represents the control difference dimension. To define a slice of the 4-dimensional array, these letters are put into an AB|CD pattern. The two letters to the right of the vertical bar define which variables are held constant. The two letters to the left of the vertical bar define which variables are going to show up in the rows (first letter) and in the columns (second letter). For example if tab_type equals WX|YZ, then effect and control differences will be held constant, while sample size will be represented by the rows in the generated table and a0 values will be represented by the columns. The actual values that are printed in the tables depend on what measure is requested in the parameter measure.

It is very important to populate the values of subj_per_arm_val, a0_vals, effect_val, and rand_control_diff_val correctly given the value of tab_type, when the object of class bayes_ctd_array is created by historic_sim() and at least 3 of the four parameters have more than one value. On the other hand, if 2 or more of the four parameters have only one value, then subj_per_arm_val, a0_vals, effect_val, rand_control_diff_val, as well as tab_type can be ignored. If the last two letters are YZ, then effect_val and rand_control_diff_val must be populated. If the last two letters are XZ, then a0_vals and rand_control_diff_val must be populated. If the last two letters are XY, then a0_vals and effect_val must be populated. If the last two letters are WZ, then sample_val and rand_control_diff_val must be populated. If the last two letters are WY, then sample_size_val and effect_val must be populated. If the last two letters are WX, then sample_size_val and a0_vals must be populated.

If the object of class bayes_ctd_array is created by simple_sim(), the parameters tab_type, subj_per_arm_val, a0_vals, effect_val, and rand_control_diff_val are ignored.

Value

print() returns a two dimensional array of simulation results.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#Run a Weibull simulation, using simple_sim().
#For meaningful results, trial_reps needs to be much larger than 2.
weibull_test <- simple_sim(trial_reps = 2, outcome_type = "weibull",
                           subj_per_arm = c(50, 100, 150, 200),
                           effect_vals = c(0.6, 1, 1.4),
                           control_parms = c(2.82487,3),
                           time_vec = NULL, censor_value = NULL,
                           alpha = 0.05, get_var = TRUE,
                           get_bias = TRUE, get_mse = TRUE,
                           seedval=123, quietly=TRUE)

#Tabulate the simulation results for power.
test_table <- print(x=weibull_test, measure="power",
                    tab_type=NULL, subj_per_arm_val=NULL, a0_val=NULL,
                    effect_val=NULL, rand_control_diff_val=NULL)
print(test_table)

#Tabulate the simulation results for estimates.
print(x=weibull_test, measure="est")

#Tabulate the simulation results for variance.
print(x=weibull_test, measure="var")

#Tabulate the simulation results for bias.
print(x=weibull_test, measure="bias")

#Tabulate the simulation results for mse.
print(x=weibull_test, measure="mse")


#Run another weibull simulation, using historic_sim().
#Note: historic_sim() can take a while to run.
#Generate a sample of historical data for use in example.
set.seed(2250)
SampleHistData <- genweibulldata(sample_size=60, scale1=2.82487,
                                 hazard_ratio=0.6, common_shape=3,
                                 censor_value=3)
histdata <- subset(SampleHistData, subset=(treatment==0))
histdata$id <- histdata$id+10000

#For meaningful results, trial_reps needs to be larger than 100.
weibull_test2 <- historic_sim(trial_reps = 100, outcome_type = "weibull",
                              subj_per_arm = c(50, 100, 150, 200, 250),
                              a0_vals = c(0, 0.33, 0.67, 1),
                              effect_vals = c(0.6, 1, 1.4),
                              rand_control_diff = c(0.8, 1, 1.2),
                              hist_control_data = histdata, time_vec = NULL,
                              censor_value = 3, alpha = 0.05, get_var = TRUE,
                              get_bias = TRUE, get_mse = TRUE, seedval=123,
                              quietly=TRUE)

#Tabulate the simulation results for power.
test_table <- print(x=weibull_test2, measure="power",
                    tab_type="WX|YZ", effect_val=0.6,
                    rand_control_diff_val=1.0)
print(test_table)

#Tabulate the simulation results for estimates.
print(x=weibull_test2, measure="est", tab_type="WX|YZ",
      effect_val=0.6, rand_control_diff_val=1.0)

#Tabulate the simulation results for variance.
print(x=weibull_test2, measure="var", tab_type="WX|YZ",
      effect_val=0.6, rand_control_diff_val=1.0)

#Tabulate the simulation results for bias.
print(x=weibull_test2, measure="bias", tab_type="WX|YZ",
      effect_val=0.6, rand_control_diff_val=1.0)

#Tabulate the simulation results for mse.
print(x=weibull_test2, measure="mse", tab_type="WX|YZ",
      effect_val=0.6, rand_control_diff_val=1.0)



#Run a Bernoulli simulation, using historic_sim().
#Generate a sample of historical Bernoulli data for use in example.
set.seed(2250)
samplehistdata <- genbernoullidata(sample_size=60, prob1=0.6, odds_ratio=0.6)
histdata <- subset(samplehistdata, subset=(treatment==0))
histdata$id <- histdata$id+10000

#For meaningful results, trial_reps needs to be larger than 100.
bernoulli_test <- historic_sim(trial_reps = 100, outcome_type = "bernoulli",
                              subj_per_arm = c(150),
                              a0_vals = c(1.0),
                              effect_vals = c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0),
                              rand_control_diff = c(1.8),
                              hist_control_data = histdata, time_vec = NULL,
                              censor_value = 3, alpha = 0.05, get_var = TRUE,
                              get_bias = TRUE, get_mse = TRUE, seedval=123,
                              quietly=TRUE)
test_table <- print(x=bernoulli_test, measure="power",
                    tab_type=NULL, effect_val=NULL,
                    subj_per_arm_val=NULL)
print(test_table)

#If only one or two of the subj_per_arm, a0_vals, effect_vals, or
#rand_control_diff parameters have length greater than 1, then
#only bayes_ctd_array and measure parameters are needed.
#Tabulate the simulation results for estimates.
print(x=bernoulli_test, measure="est")

#Tabulate the simulation results for variance.
print(x=bernoulli_test, measure="var")

#Tabulate the simulation results for bias.
print(x=bernoulli_test, measure="bias")

#Tabulate the simulation results for mse.
print(x=bernoulli_test, measure="mse")

begglest/BayesCTDesign documentation built on Nov. 29, 2021, 10:34 p.m.