ClusterDepth.calc_clusterdepthMethod

calc_clusterdepth(data,τ)

returns tuple with three entries: 1:maxLength, maximal clustervalue per clusterdepth head, same for tail

We assume data and τ have already been transformed for one/two sided testing, so that we can do d0.>τ for finding clusters

ClusterDepth.clusterMethod

finds neighbouring clusters in the vector and returns start + length vectors

if the first and last cluster start on the first/last sample, we dont know their real depth

Input is assumed to be a thresholded Array with only 0/1
ClusterDepth.clusterdepthMethod

clusterdepth(rng,data::AbstractArray;τ=2.3, statfun=x->abs.(studentt(x)),permfun=signpermute!,nperm=5000,pvaltype=:troendle)

calculate clusterdepth of given datamatrix.

• data: statfun will be applied on last dimension of data (typically this will be subjects)

Optional

• τ: Cluster-forming threshold
• nperm: number of permutations, default 5000
• stat_type: default the one-sample t-test, custom function can be specified (see statfun! and statfun)
• side_type: default: :abs - what function should be applied after the statfun? could be :abs, :square, :positive to test positive clusters, :negative to test negative clusters. Custom function can be provided, see sidefun
• perm_type: default :sign for one-sample data (e.g. differences), performs sign flips. custom function can be provided, see permfun
• pval_type: how to calculate pvalues within each cluster, default :troendle, see ?pvals
• statfun / statfun! a function that either takes one or two arguments and aggregates over last dimension. in the two argument case we expect the first argument to be modified inplace and provide a suitable Vector/Matrix.
• sidefun: default abs. Provide a function to be applied on each element of the output of statfun.
• permfun function to permute the data, should accept an RNG-object and the data. can be inplace, the data is copied, but the same array is shared between permutations
ClusterDepth.multicol_minimumMethod
calculates the minimum in X along dims=2 in the columns specified by àrrayOfIndicearrays which could be e.g. [[1,2],[5,6],[3,4,7]]
ClusterDepth.pvalsMethod

pvals(data;kwargs...) = pvals(data[2:end],data[1];kwargs...)

pvals(data::AbstractVector,stat::Real;type=:twosided)

calculates pvalues based on permutation results

if called with stat, first entry is assumed to be the observation

ClusterDepth.studentt_test!Method
studentt_test!(out,x;type=:abs)

strongly optimized one-sample t-test function.

Implements: t = mean(x) / ( sqrt(var(x))) / sqrt(size(x,2)-1)

Accepts 2D or 3D matrices, always aggregates over the last dimension

ClusterDepth.troendleMethod

function troendle(perm::AbstractMatrix,stat::AbstractVector;type=:twosided)

Multiple Comparison Correction as in Troendle 1995

perm with size ntests x nperms

stat with size ntests

type can be :twosided (default), :lesser, :greater

Heavily inspired by the R implementation in permuco from Jaromil Frossard

Note: While permuco is released under BSD, the author Jaromil Frossard gave us an MIT license for the troendle and the clusterdepth R-functions.