power: Method of RCTtoolbox: 'power()'

powerR Documentation

Method of RCTtoolbox: power()

Description

When you create R6 object "RCTtoolbox" via link{create_RCTtoolbox}() and run its method power(), the method internally implements a function that performs power analysis. The method power() provides some arguments. See the section "Arguments."

Arguments

ctrl

character. New control arm. If NULL (default), the first element of treat_levels is control arm.

subset

subset condition. If NULL (default), full observations of data is used to implement power analysis.

sd

numeric. standard deviation (default is 1). Absolute mean difference between two groups is calculated by effect size times sd.

...

arguments passed to ttest_power(). This function has five arguments: n0, n1, d, alpha, and beta. This method automatically specify the first two arguments. Users must specify two of d (effect size), alpha (significant level), and beta (power) in dot-dot-dot. This method calculate one missing argument using uniroot.

Value

R6 object with "RCTtoolbox.power.analysis" class. The returned object has following field and methods:

result

Field. Data frame including estimated result. See the section "Result Field."

print()

Method. Print information about the returned object. Run $print().

table()

Method. Create output table of result. Run $plot().

summary()

Method. Print result in console. Run $summary().

Result Field

The R6 object with "RCTtoolbox.power.analysis" class has result field. This field has a data frame with 8 variables:

n0

Number of observations of control arm

n1

Number of observations of each experimental arm

arms

Factor. Experimental arms. The first level is control arm.

d

Effect size

alpha

Significant level

power

Power

sd

Standard deviation

diff_mean

Absolute mean difference of two groups

Developer Note

A method power() provided by R6 object RCTtoolbox implements RCTtoolbox.power.analysis$new() which generates R6 object with "RCTtoolbox.power.analysis" class. Initialization of R6 object "RCTtoolbox.ttest" run power_calculation(private$dvec, self$data, private$dvec.levels, private$dvec.labels, ...) where ... accepts arguments explained in the section "Arguments." The first four arguments passed to ttest_multi_mod_arm() are

treat

Character. Treatment Variable. The method power() automatically passes the private field dvec of R6 object "RCTtoolbox" to this argument.

data

data.frame/tibble object that you want to use. The method power() automatically passes a public field data of R6 object "RCTtoolbox" to this argument.

treat_levels

character vector. Level of experimental arms. The first element is control arm. The method power() automatically passes the private field dvec.levels of R6 object "RCTtoolbox" to this argument.

treat_labels

character vector. Label of experimental arms corresponding to treat_levels. The method power() automatically passes the private field dvec.labels of R6 object "RCTtoolbox" to this argument.

Examples

## Not run: 
data(RubellaNudge)
rct <- create_RCTtoolbox(
  atest + avacc ~ treat,
  data = RubellaNudge,
  treat_levels = LETTERS[1:7]
)

# calculate effect size
rct$power(alpha = 0.05, power = 0.8)$summary()
# calculate effect size with control arm "C"
rct$power(alpha = 0.05, power = 0.8, ctrl = "C")$result

## End(Not run)


KatoPachi/RCTtoolbox documentation built on April 20, 2022, 8:17 a.m.