Skip to contents

When permutation_test == FALSE (the default), this function bootstrap samples from an AFQ dataframe and returns pairwise differences at each node for each bootstrap sample. These results can then be used to construct bootstrap confidence intervals for the node-wise differences.

Usage

sampling_test(
  df_tract,
  n_samples,
  dwi_metric,
  tract,
  group_by = "group",
  participant_id = "subjectID",
  sample_uniform = FALSE,
  covariates = NULL,
  smooth_terms = NULL,
  k = NULL,
  family = NULL,
  formula = NULL,
  factor_a = NULL,
  factor_b = NULL,
  permute = FALSE
)

Arguments

df_tract

AFQ Dataframe of node metric values for single tract

n_samples

Number of sample tests to perform

dwi_metric

The diffusion metric to model (e.g. "FA", "MD")

tract

AFQ tract name

group_by

The grouping variable used to group nodeID smoothing terms

participant_id

The name of the column that encodes participant ID

sample_uniform

Boolean flag. If TRUE, shuffling should sample uniformly from the unique values in the columns. If FALSE, shuffling will shuffle without replacement.

covariates

List of strings of GAM covariates, not including the smoothing terms over nodes and the random effect due to subjectID.

smooth_terms

Smoothing terms, not including the smoothing terms over nodes and the random effect due to subjectID.

k

Dimension of the basis used to represent the node smoothing term

family

Distribution to use for the gam. Must be 'gamma' or 'beta'

formula

Optional explicit formula to use for the GAM. If provided, this will override the dynamically generated formula build from the target, covariate, and k inputs. Default = NULL.

factor_a

First group factor, string

factor_b

Second group factor, string

permute

Boolean flag. If TRUE, perform a permutation test. Otherwise, do a bootstrap simulation.

Value

Dataframe with bootstrap or permutation test coefficients

Details

When permutation_test == TRUE, this function simulates the null distribution using permutation testing. That is, it shuffles to destroy any relationships between covariates and dwi_metrics. It then computes node-wise differences for each shuffled sample.

Examples

if (FALSE) { # \dontrun{
df_afq <- read.csv("/path/to/afq/output.csv")
df_tract <- df_afq[which(df_afq$tractID == tract), ]
bootstrap_coefs <- sampling_test(df_afq,
                                 dwi_metric = "dti_fa",
                                 covariates = list("group", "sex"),
                                 family = "gamma",
                                 k = 40,
                                 n_samples = 1000)
} # }