Package ‘odr’

Zuchao Shen, Ben Kelcey

2020-03-13

The costs of sampling each additional unit in multilevel experimental studies vary across levels of hierarchy and treatment conditions due to the hierarchical sampling and the delivery of treatment. This package is a tool to optimize the designs of multilevel experimental studies such that the variances of treatment effects are minimized under a fixed budget and cost structure, or the budget is minimized to achieve same level design precision or statistical power. The optimal sample allocation or optimal design parameters include

This package includes three categorical of functions and they are

1. Function od

Given cost structure (i.e., the costs of sampling each unit at different levels and treatment conditions), this function solves the optimal sample allocation with and without constraints.

To solve the optimal sample allocation of a two-level cluster-randomized trial, we need the following information

1.1 Examples

## The optimal level-1 sample size per level-2 unit (n) is 8.878572.
## The optimal proportion of level-2 units in treatment (p) is 0.326828.

## The constrained level-1 sample size per level-2 unit (n) is 20.
## The optimal proportion of level-2 units in treatment (p) is 0.3740667.

## The optimal level-1 sample size per level-2 unit (n) is 10.48809.
## The constrained proportion of level-2 units in treatment (p) is 0.5.

## ===============================
## Both p and n are constrained, there is no calculation from other parameters.
## ===============================
## The constrained level-1 sample size per level-2 unit (n) is 20.
## The constrained proportion of level-2 units in treatment (p) is 0.5.

1.2 Examples for other types of trials

Please see examples in corresponding functions by uncommenting below lines.

2. Function power

This function by default can perform power analyses accommodating cost structures (i.e., cost.model = TRUE), one of ‘power’, ‘m’, and ‘d’ must be NULL. For example, if ‘power’ is NULL, the function calculates statistical power under a fixed budget and cost structure; if ‘d’ is NULL, the function calculates minimum detectable effect size (i.e., d) under a fixed budget and desired power level; if ‘m’ is NULL, the function calculate required budget (and required sample size) to achieve desired power level to detect a treatment effect.

This function also can conduct conventional power analysis or power analysis wihout accommodating cost structures by specifying cost.model = FALSE, the conventional power analyses include statistical power calculation, minimum detectable effect size calculation, and required sample size calculation.

2.1 Examples of power analyses accommodating cost structures (cost.model = TRUE)

2.2 Examples of conventional power analyses (cost.model = FALSE)

## $J
## [1] 58.99295
## $power
## [1] 0.8000486
## $d
## [1] 0.2999819

2.3 Examples of conventional power curves

2.4 Examples for other types of trials

Please see examples in corresponding functions by uncommenting below lines.

3. Function re

Calculate the relative efficiency (RE) of two designs, this function uses the returns from od function

3.1 Examples

Based on above examples in od functions, calculate the relative efficiency

## The relative efficiency (RE) of the two two-level CRTs is 0.8790305.
## [1] 0.8790305
## The relative efficiency (RE) of the two two-level CRTs is 0.8975086.
## The relative efficiency (RE) of the two two-level CRTs is 0.8266527.

3.2 Examples for other types of trials

For additional examples, please see example sections in corresponding od functions by uncommenting below lines.