balance: Method of RCTtoolbox: 'balance()'

balanceR Documentation

Method of RCTtoolbox: balance()

Description

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

weights

weight variable for weighted least squares. If NULL (default), implement ordinary least squares.

cluster

cluster variable for clustered standard error. If NULL (default), standard error is not clustered.

...

arguments passed to lm_robust.

Value

R6 object with "RCTtoolbox.balance.test" class. The returned object has following field and methods:

result

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

print()

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

table()

Method. Create output table of balance test. Run $table().

Result Field

The R6 object with "RCTtoolbox.balance.test" class has result field. This field has a data frame with 3 variables:

x

Character. Covariates.

item

Factor. Label of experimental arms, f-value, degree of freedoms of F-distribution, p-value of F.

val

Numeric. Value corresponding to item.

Developer Note

The method balance() provided by R6 object RCTtoolbox implements RCTtoolbox.balance.test$new() which generates R6 object with "RCTtoolbox.balance.test" class. Initialization of R6 object "RCTtoolbox.balance.test" run balance_test_multi_var(private$xvec, private$dvec, self$data, private$dvec.levels, private$dvec.labels, ...) where ... accepts arguments explained in the section "Arguments." The first five arguments passed to balance_test_multi_var() are

covariate

Character vector. Covariate. The method balance() automatically passes the private field xvec of R6 object "RCTtoolbox" to this argument.

treat

Character vector. Treatment. The method balance() 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 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,
    ~ age + educ,
    RubellaNudge,
    LETTERS[1:7]
  )

# balance test
rct$balance()$result

## End(Not run)


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