Skip to contents

The analyze function can be used calculate the values of a list of point estimators, confidence intervals, and p-values for a given dataset.

Usage

analyze(
  data,
  statistics = list(),
  data_distribution,
  use_full_twoarm_sampling_distribution = FALSE,
  design,
  sigma,
  exact = FALSE
)

# S4 method for class 'data.frame'
analyze(
  data,
  statistics = list(),
  data_distribution,
  use_full_twoarm_sampling_distribution = FALSE,
  design,
  sigma,
  exact = FALSE
)

Arguments

data

a data.frame containing the data to be analyzed.

statistics

a list of objects of class PointEstimator, ConfidenceInterval or PValue.

data_distribution

object of class Normal or Student.

use_full_twoarm_sampling_distribution

logical indicating whether this estimator is intended to be used with the full sampling distribution in a two-armed trial.

design

object of class TwoStageDesign.

sigma

assumed standard deviation.

exact

logical indicating usage of exact n2 function.

Value

Results object containing the values of the statistics when applied to data.

Details

Note that in adestr, statistics are codes as functions of the stage-wise sample means (and stage-wise sample variances if data_distribution is Student). In a first-step, the data is summarized to produce these parameters. Then, the list of statistics are evaluated at the values of these parameters.

The output of the analyze function also displays information on the hypothesis test and the interim decision. If the statistics list is empty, this will be the only information displayed.

Examples

set.seed(123)
dat <- data.frame(
  endpoint = c(rnorm(28, 0.3)),
  stage = rep(1, 28)
)
analyze(data = dat,
        statistics = list(),
        data_distribution = Normal(FALSE),
        design = get_example_design(),
        sigma = 1)
#> Design:                               TwoStageDesign<n1=28;0.8<=x1<=2.3:n2=9-40>
#> Data Distribution:                                          Normal<single-armed>
#> Observed number of stages:                                                     1
#> Observed n1 (total)                                                           28
#> Z1                                                                           1.3
#> Interim decision:                                       continue to second stage
#> Calculated n2(Z1) (per group)                                           32.21129
#> Calculated c2(Z1)                                                           1.71
#> 

# The results suggest recruiting 32 patients for the second stage
dat <- rbind(
  dat,
  data.frame(
    endpoint = rnorm(32, mean = 0.3),
    stage = rep(2, 32)))
analyze(data = dat,
        statistics = get_example_statistics(),
        data_distribution = Normal(FALSE),
        design = get_example_design(),
        sigma = 1)
#> Design:                               TwoStageDesign<n1=28;0.8<=x1<=2.3:n2=9-40>
#> Data Distribution:                                          Normal<single-armed>
#> Observed number of stages:                                                     2
#> Observed n1 (total)                                                           28
#> Z1                                                                           1.3
#> Interim decision:                                       continue to second stage
#> Calculated n2(Z1) (per group)                                           32.21129
#> Calculated c2(Z1)                                                           1.71
#> Observed n2 (in total)                                                        32
#> Z2                                                                          2.66
#> Final test decision:                                                 reject null
#> 
#> Stage 2 results:
#>  Sample mean:                                                          0.3656173
#>  Pseudo Rao-Blackwellized:                                             0.3135628
#>  Median unbiased (LR test ordering):                                   0.3420742
#>  Bias reduced MLE (iterations=1):                                       0.357214
#>  SWCF ordering CI:                                       [0.04664821, 0.6142449]
#>  LR test ordering CI:                                    [0.08992822, 0.6106096]
#>  SWCF ordering p-value:                                               0.01321363
#>  LR test ordering p-value:                                           0.003551316
#>