atm_diff: Calculate the difference of asymmetric trimmed means between...

Description Usage Arguments Details Value Examples

View source: R/trimmed_mean.R

Description

Calculate the difference in asymmetric trimmed means between Y and X. The percent trimmed from left (α) and right ((β)) are chosen adaptively using grid search. If gridsize = 'sqrtn', the grid of α and β values are spaced by 1/sqrt(n) where n is the size of the smaller group. If gridsize = 'n', the grid values are spaced by 1/n. Note that the two-dimensional grid search is then of size n^2 which can be prohibitively slow for large n, while sqrt(n) will be near optimal and feasible even for large samples. Alternatively, specify any integer of at least 3, up to the size of the smaller group.

Usage

1
2
3
4
5
6
7
8
9
atm_diff(
  X,
  Y,
  gridsize = "sqrtn",
  max_alpha = 1,
  max_beta = 1,
  min_frac = 0.25,
  min_obs = 50
)

Arguments

X

numeric vector, the outcomes of the control observations.

Y

numeric vector, the outcomes of the treated observations.

gridsize

either the string 'sqrtn' or 'n' or an integer giving the number of alpha and beta values to try

max_alpha

numeric between 0 and 1, the maximum fraction of observations to trim from the left (default 1)

max_beta

numeric between 0 and 1, the maximum fraction of observations to trim from the right (default 1)

min_frac

numeric between 0 and 1, the minimum fraction of observations to KEEP after trimming (default 0.25)

min_obs

numeric, the minimum number of observations of each treatment state to KEEP after trimming (default 50)

Details

The parameters max_alpha and max_beta allow to set bounds for the amount of trimming from the left and right, respectively. Note that the grid spacing is not affected by this; that is, fewer values of α or β need to be searched over when changing the defaults. To only consider trimming of up to the smallest 3 To only trim the right tail of the data, set max_alpha = 0; forcing the function to not trim the left tail may improve stability when appropriate, and should be much faster computationally. The size of the sample after trimming is 1 - α - β where α and β are the selected trimming percentages.

Value

list of four elements:

tau

the point estimate of the treatment effect

se

the estimated standard error (if calc_se = TRUE)

alpha

the trimming fraction from the left

beta

the trimming fraction from the right

Examples

1
2
3
4
5
6
7
8
# draw a random sample with additive treatment effect
X <- rnorm(n=1000)
Y <- rnorm(n=1000)
atm_diff(X,Y)
# for smaller samples, a n-grid may be computationally feasible
X <- rnorm(n=100)
Y <- rnorm(n=100)
atm_diff(X,Y, gridsize='n')

michaelpollmann/parTreat documentation built on Dec. 21, 2021, 5:58 p.m.