Skip to contents

This function returns a function that carries with it the environment containing the arguments. The idea is to make parallelization easier.

Usage

padj_test_fn(
  idat,
  bdat,
  blockid,
  trtid = "trt",
  fmla = Y ~ trtF | blockF,
  ybase,
  prop_blocks_0,
  tau_fn,
  tau_size,
  by_block = TRUE,
  pfn,
  afn,
  p_adj_method,
  nsims,
  ncores = 1,
  splitfn = NULL,
  covariate = NULL,
  splitby = NULL,
  thealpha = 0.05,
  stop_splitby_constant = TRUE,
  return_details = FALSE
)

Arguments

idat

Individual level data

bdat

Data at the block level.

blockid

A character name of the column in idat and bdat indicating the block.

trtid

Is the name of the treatment numeric, (0,1), variable

fmla

A formula with outcome~treatment assignment | block where treatment assignment and block must be factors.

ybase

Is the potential outcome to control upon which the treatment effect will be built

prop_blocks_0

Is the proportion of blocks with no effects at all

tau_fn

Is a function that turns ybase into the potential outcome under treatment — it is a treatment effect creating function.

tau_size

Is the parameter for the tau_fn — like the true average effect size within a block.

by_block

Is an argument to create_effects to create true effects by block or across the whole dataset

pfn

A function to produce pvalues — using idat.

afn

A function to adjust alpha at each step. Takes one or more p-values plus a stratum or batch indicator.

p_adj_method

Is "split" to use findBlocks for top-down testing and "fdr" or "holm" etc to use stats::p.adjust and do the test in every block.

nsims

Is the number of simulations to run — each simulation uses the same treatment effects be re-assigns treatment (re-shuffles treatment and re-reveals the observed outcomes as a function of the potential outcomes)

ncores

Tells p-value functions how many cores to use. Mostly ignored in use of this function because we are tending to parallelize at higher loops.

splitfn

A function to split the data into two pieces — using bdat

covariate

is the name of a covariate to be used in created covariate dependent treatment effects. If NULL then the tau_fn should not use a covariate. If "newcov", then create a new covariate with a known (moderate) relationship with the potential outcome under control. This relationship is currently fixed with an R^2 of about .1.

splitby

A string indicating which column in bdat contains a variable to guide splitting (for example, a column with block sizes or block harmonic mean weights or a column with a covariate (or a function of covariates))

thealpha

Is the error rate for a given test (for cases where alphafn is NULL, or the starting alpha for alphafn not null)

stop_splitby_constant

TRUE is the algorithm should stop splitting when the splitting criteria is constant within set/parent or whether it should continue but split randomly.

return_details

TRUE means that the function should return a list of the original data ("detobj"), a summary of the results ("detresults"), and a node level dataset ("detnodes"). Default here is FALSE. Only use TRUE when not using simulations.

Value

A pvalue for each block