analysis_Qstatistic: Calculate confidence interval for cross site variation using...

View source: R/analysis_Qstatistic.R

analysis_Qstatistic_statR Documentation

Calculate confidence interval for cross site variation using Q-statistic test inversion.

Description

Two versions of this, one that takes raw data (in which case a linear model is fit to it to get individual site impact estimates), and a second, '_stat', that takes precalculated point estimates and standard errors.

Usage

analysis_Qstatistic_stat(
  ATE_hat,
  SE_hat,
  alpha = 0.05,
  calc_CI = FALSE,
  calc_optim_pvalue = FALSE,
  verbose = FALSE,
  tolerance = 1e-05,
  mean_method = c("weighted", "raw")
)

analysis_Qstatistic(
  Yobs,
  Z,
  B,
  siteID = NULL,
  data = NULL,
  alpha = 0.05,
  calc_CI = FALSE
)

Arguments

ATE_hat

List of estimated ATEs, one for each site.

SE_hat

List of associated estimated SEs, assumed to be known.

alpha

The level of the test. The CI will be a 1-2alpha confidence interval.

calc_CI

Logical, TRUE means calculate the confidence interval using test-inversion.

calc_optim_pvalue

TRUE if estimate cross site variation by maximizing p-value (a type of Hodges-Lehman estimate). FALSE means uses Konstantopoulos and Hedges direct formula. (TRUE requires calc_CI also be set to TRUE.) Default of FALSE. FALSE recommended.

verbose

Print out a few diagnostics as the CI is being calculated, for those curious.

tolerance

For optimization and search for CI endpoints, how close to optimal do we want?

mean_method

How to calculate the mean effect. 'weighted' is a precision weighted mean. 'raw' is the simple mean. Or pass a number which will be used as the mean.

Yobs

(outcome)

Z

(binary treatment 0/1)

B

(site id)

siteID

If not null, name of siteID that has randomization blocks

data

frame holding Y, Z, B and (possibly a column with name specified by siteID).

Details

The first simply calculates ATE_hat and SE_hat, and then calls the second.

Cross site variation, by default, is estimated by method of moments technique of Konstantopoulos and Hedges). One can set an alternate method for estimating cross-site variation via using optim() to find the point estimate corresponding to maximizing the p-value (this differs slightly from direct method of moment); this latter approach requires calculating the confidence interval using test inversion as well.

Code based on prior work of Catherine Armstrong, which was then augmented to do binary search for endpoints for the test inversion procedure to generate confidence intervals.

Value

List of several estimated quantities: cross-site variation (standard deviation, not variance), p-value for presence of any variation, flag of whether the p-value is less than passed alpha, the Q statistic itself, and the confidence interval.

Examples

analysis_Qstatistic_stat( rnorm(30, sd=0.1), rep(0.1,30), calc_CI = TRUE )

lmiratrix/blkvar documentation built on Nov. 18, 2024, 1:27 p.m.