DesignWeights: Create stratum weights to be associated with a DesignOptions

View source: R/Design.R

DesignWeightsR Documentation

Create stratum weights to be associated with a DesignOptions

Description

Apply weighting function to a DesignOptions by stratum, returning results in a format suitable to be associated with an existing design and used in further calcs.

Usage

DesignWeights(design, stratum.weights = harmonic_times_mean_weight)

Arguments

design

DesignOptions

stratum.weights

Stratum weights function. Will be fed a count data.frame with Tx.grp (indicating the treatment group), stratum.code, all other covariates and unit.weights.

Details

The function expects its DesignOptions argument to represent aggregated data, i.e. clusters not elements within clusters. Its stratum.weights argument is a function that is applied to a data frame representing clusters, with variables Tx.grp, stratum.code, covariates as named in the design argument (a DesignOptions object), and unit.weights (either as culled or inferred from originating balanceTest call or as aggregated up from those unit weights). Returns a weighting factor to be associated with each stratum, this factor determining the stratum weight by being multiplied by mean of unit weights over clusters in that stratum.

Specifically, the function's value is a data frame of two variables, sweights and wtratio, with rows representing strata. The sweights vector represents internally calculated or user-provided stratum.weights, one for each stratum, scaled so that their sum is 1; in Hansen & Bowers (2008), these weights are denoted w_{b}. wtratio is the ratio of sweights to the product of half the harmonic mean of n_{tb} and n_{cb}, the number of treatment and control clusters in stratum b, with the mean of the weights associated with each of these clusters. In the notation of Hansen & Bowers (2008), this is w_{b}/(h_b \bar{m}_b). Despite the name ‘wtratio’, this ratio's denominator is not a weight in the sense of summing to 1 across strata. The ratio is expected downstream in HB08 (in internal calculations involving ‘wtr’).

Value

data frame w/ rows for strata, cols sweights and wtratio.


RItools documentation built on June 22, 2024, 9:06 a.m.