SeqDesignInference: Inference for A Sequential Design

Description Public fields Methods Examples

Description

An R6 Class that estimates, tests and provides intervals for a treatment effect in a sequential design. This class takes a SeqDesign object as an input where this object contains data for a fully completed sequential experiment (i.e. all treatment assignments were allocated and all responses were collected). Then the user specifies the type of estimation (difference-in-means or OLS) and the type of sampling assumption (i.e. the superpopulation assumption leading to normal-based inference or the finite population assumption implying randomization-exact-based inference) and then can query the estimate and pval for the test. If the test is normal-theory based it is testing the population H_0: beta_T = 0 and if the test is a randomization test, it is testing the sharp null that H_0: Y_T_i = Y_C_i for all subjects. Confidence interval construction is available for normal-theory based test type as well.

Public fields

estimate_type

The type of estimate to compute (either "difference-in-means" or "OLS").

test_type

The type of test to run (either "normal-based" or "randomization-exact").

num_cores

The number of CPU cores to employr during sampling within randomization inference

verbose

A flag that indicates whether messages should be displayed to the user

Methods

Public methods


Method new()

Initialize a sequential experimental design estimation and test object after the sequential design is completed.

Usage
SeqDesignInference$new(
  seq_des_obj,
  estimate_type = "OLS",
  test_type = "randomization-exact",
  num_cores = 1,
  verbose = TRUE
)
Arguments
seq_des_obj

A SeqDesign object whose entire n subjects are assigned and response y is recorded within.

estimate_type

The type of estimate to compute (either "difference-in-means" or "OLS"). Default is "OLS" as this provided higher power in our simulations.

test_type

The type of test to run (either "normal-based" implying your subject entrant sampling assumption is from a superpopulation or "randomization-exact" implying a finite sampling assumption). The default option is "randomization-exact" as it provided properly-sized tests in our simulations.

num_cores

The number of CPU cores to use to parallelize the sampling during randomization-based inference (which is very slow). The default is 1 for serial computation. This parameter is ignored for test_type = "normal-based".

verbose

A flag indicating whether messages should be displayed to the user. Default is TRUE

Returns

A new 'SeqDesignTest' object.

Examples
seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
 

Method compute_treatment_estimate()

Computes either the classic different-in-means estimate of the additive treatment effect, i.e. ybar_T - ybar_C or the OLS estimate of the additive treatment effect linearly i.e. the treatment different adjusted linearly for the p covariates.

Usage
SeqDesignInference$compute_treatment_estimate()
Returns

The numeric estimate of the treatment effect

Examples
seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
seq_des_inf$compute_treatment_estimate()
		

Method compute_pval_for_no_treatment_effect()

Computes either the classic different-in-means estimate of the additive treatment effect, i.e. ybar_T - ybar_C or the OLS estimate of the additive treatment effect linearly i.e. the treatment different adjusted linearly for the p covariates.

Usage
SeqDesignInference$compute_pval_for_no_treatment_effect(nsim_exact_test = 501)
Arguments
nsim_exact_test

The number of randomization vectors to use in the randomization test (ignored if test_type is not "randomization-exact"). The default is 501 providing pvalue resolution to a fifth of a percent.

Returns

The frequentist p-val for the test of nonzero treatment effect

Examples
seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
seq_des_inf$compute_pval_for_no_treatment_effect()
		

Method randomization_inference_samples_for_no_treatment_effect()

Computes many randomization samples of either the classic different-in-means estimate of the additive treatment effect, i.e. ybar_T - ybar_C or the OLS estimate of the additive treatment effect linearly i.e. the treatment different adjusted linearly for the p covariates. This function is useful if you wish to run your own, custom hypothesis tests.

Usage
SeqDesignInference$randomization_inference_samples_for_no_treatment_effect(
  nsim_exact_test = 501
)
Arguments
nsim_exact_test

The number of randomization vectors. The default is 501 providing pvalue resolution to a fifth of a percent.

Returns

The nsim_exact_test samples of the treatment effect under the null hypothesis of no treatment effect where each sample is estimated from a different assignment vector for the prespecified design

Examples
seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
samps = seq_des_inf$randomization_inference_samples_for_no_treatment_effect()
summary(samps)	


Method compute_confidence_interval()

Computes either a:

1. classic frequentist confidence interval (CI) of the additive treatment effect employing the normal theory approximation for both the (a) difference in means estimator i.e. [ybar_T - ybar_C +/- t_alpha/2, n_T + n_C - 2 s_ybar_T - ybar_C] or (b) the OLS estimator i.e. [beta_hat_T +/- t_alpha/2, n + p - 2 s_beta_hat_T] where the z approximation is employed in lieu of the t is the design is a KK design or

2. a randomization-based CI of an additive shift effect of the potential outcomes under treatment and control by an inversion of the randomization test at level alpha (this feature is incomplete).

Usage
SeqDesignInference$compute_confidence_interval(
  alpha = 0.05,
  nsim_exact_test = 501
)
Arguments
alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.

nsim_exact_test

The number of randomization vectors. The default is 1000 providing good resolutions to confidence intervals.

Returns

A 1 - alpha sized frequentist confidence interval for the treatment effect

Examples
seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des, test_type = "normal-based")
seq_des_inf$compute_confidence_interval()
		

Method clone()

The objects of this class are cloneable with this method.

Usage
SeqDesignInference$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

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
## ------------------------------------------------
## Method `SeqDesignInference$new`
## ------------------------------------------------

seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
 

## ------------------------------------------------
## Method `SeqDesignInference$compute_treatment_estimate`
## ------------------------------------------------

seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
seq_des_inf$compute_treatment_estimate()
		

## ------------------------------------------------
## Method `SeqDesignInference$compute_pval_for_no_treatment_effect`
## ------------------------------------------------

seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
seq_des_inf$compute_pval_for_no_treatment_effect()
		

## ------------------------------------------------
## Method `SeqDesignInference$randomization_inference_samples_for_no_treatment_effect`
## ------------------------------------------------

seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des)
samps = seq_des_inf$randomization_inference_samples_for_no_treatment_effect()
summary(samps)	


## ------------------------------------------------
## Method `SeqDesignInference$compute_confidence_interval`
## ------------------------------------------------

seq_des = SeqDesign$new(n = 6, p = 10, design = "CRD")
seq_des$add_subject_to_experiment(c(1, 38, 142, 71, 5.3, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(0, 27, 127, 60, 5.5, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 42, 169, 74, 5.1, 0, 1, 0, 0, 0))
seq_des$add_subject_to_experiment(c(0, 59, 105, 62, 5.9, 0, 0, 0, 1, 0))
seq_des$add_subject_to_experiment(c(1, 32, 186, 66, 5.6, 1, 0, 0, 0, 0))
seq_des$add_subject_to_experiment(c(1, 37, 178, 75, 6.5, 0, 0, 0, 0, 1))
seq_des$add_all_subject_responses(c(4.71, 1.23, 4.78, 6.11, 5.95, 8.43))

seq_des_inf = SeqDesignInference$new(seq_des, test_type = "normal-based")
seq_des_inf$compute_confidence_interval()
		

SeqExpMatch documentation built on June 1, 2021, 9:09 a.m.