ttest: Method of RCTtoolbox: 'ttest()'

View source: R/Method-internal-ttest.r

ttestR Documentation

Method of RCTtoolbox: ttest()

Description

When you create R6 object "RCTtoolbox" via create_RCTtoolbox and run its method ttest(), the method internally implements a function that performs two-sided t-test or permutation test. The method ttest() 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 t-test.

weights

weight variable. If NULL (default), unbiased unweighted average and std.err. is calculated.

bootse

integer. Number of bootstrap samples to calculate std.err. of mean. If 0 (default), theoretical std.err. of mean is calculated.

bootp

integer. If 0 (default), welch two-sided t-test is implemented. If 1 or more, the permutation test is implemented (the number of permutations that randomly reallocate assignment to keep the sample size collected from each group).

seed

integer. Seed value passed to the argument of set.seed.

Value

R6 object with "RCTtoolbox.ttest" 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().

plot()

Method. Visualization of result. Run $plot().

summary()

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

Result Field

The R6 object with "RCTtoolbox.ttest" class has result field. This field has a data frame with 13 variables:

mean1

Outcome average of each experimental arm

se1

Std.err. of outcome average of each experimental arm

n1

Number of observations of each experimental arm

mean0

Outcome average of control arm

se0

Std.err. of outcome average of control arm

n0

Number of observations of control arm

diff

Difference between "mean1" - "mean0"

t

t-statistics when bootp = 0L (Two-sided t-test)

df

degree of freedom of t-distribution when bootp = 0L (Two-sided t-test)

pval

p-value of difference mean test. Pr(>|t|) when bootp = 0L (Two-sided t-test). Pr(>|diff|) when bootp > 0L (Permutation test).

method

Character. Method of difference mean test.

arms

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

outcome

Character. Outcome variable.

Developer Note

A method ttest() provided by R6 object RCTtoolbox implements RCTtoolbox.ttest$new() which generates R6 object with "RCTtoolbox.ttest" class. Initialization of R6 object "RCTtoolbox.ttest" run ttest_multi_mod_arm(private$formula.yd, 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

baseline

list of two-sided formula outcome ~ treat. The method ttest() automatically passes the private field formula.yd of R6 object "RCTtoolbox" to this argument.

data

data.frame/tibble object that you want to use. The method ttest() 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 ttest() 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 ttest() 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]
  )

  # two-sided t-test
  rct$ttest()
  # permutation test with control arm "C"
  rct$ttest(bootp = 50, ctrl = "C")

## End(Not run)


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