# clusterlm: Cluster test for longitudinal data In permuco: Permutation Tests for Regression, (Repeated Measures) ANOVA/ANCOVA and Comparison of Signals

## Description

Compute the cluster-mass test for longitudinal linear model.

## Usage

 1 2 3 clusterlm(formula, data = NULL, np = 5000, method = NULL, test = "fisher", threshold = NULL, aggr_FUN = NULL, multcomp = "clustermass", ...) 

## Arguments

 formula A formula object where the left part is a matrix defined in the global environment. data A data frame for the independant variables. np The number of permutations. Default value is 5000. method A character string indicating the method used to handle nuisance variables. Default is NULL and will switch to "freedman_lane" for the fixed effects model and to "Rd_kheradPajouh_renaud" for the repeated measures ANOVA. See lmperm or aovperm for details on the permutation methods. test A character string to specify the name of the test. Default is "fisher". "t" is available for the fixed effects model. threshold A numerical value that specify the threshold for the "clustermass" multiple comparisons procedure. If it is a vector each value will be associated to an effect. If it is scalar the same threshold will be used for each test. Default value is NULL and will compute a threshold based on the 0.95 quantile of the choosen test statistic. aggr_FUN A function used as mass function. It should aggregate the statistics of a cluster into one scalar. Default is the sum of squares fot t statistic and sum for F statistic. multcomp A vector of character defining the methods of multiple comparisons to compute. Default is "clustermass", and the additional options are available : "tfce","bonferroni", "holm", "troendle" and "benjamini_hochberg". ... Futher arguments, see details.

## Details

The random effects model is only avaible with a F statistic.

Other arguments could be pass in ... :

P : A matrix containing the permutation of class matrix or Pmat; which is used for the reproductibility of the results. The first column must be the identity. P overwrites np argument.

rnd_rotation : A matrix of random value to compute a rotation of size n \times n that will be used for the "huh_jhun" method.

p_scale = FALSE : if set to TRUE, the several multiple comparisons procedures are compute on the 1 - p scale, where p is the p-value. The threshold have to be set between 0 and 1 (eg: threshold = 0.95). The function aggr_FUN should be big when there is evidence against the null (eg: aggr_FUN = function(p)sum(abs(log(1-p))). Moreover under the probability scale the cluster mass statistics is sensitive to the number permutations.

H, E, ndh : the parameters used for the "tfce" method. Default values are set to H = 2 for the height parameter, to E = 0.5 for the extend parameter and to ndh = 500 for the number terms to approximate the integral.

alpha = 0.05 : the type I error rate. Used for the troendle multiple comparisons procedure.

return_distribution = FALSE : return the permutation distribution of the statistics. Warnings : return one high dimentional matrices (number of test times number of permutation) for each test.
coding_sum : a logical defining the coding of the design matrix to contr.sum: set by default to TRUE for ANOVA (when the argument test is "fisher" ) to tests main effects and is set to FALSE when test is "t". If coding_sum is set to FALSE the design matrix is computed with the coding defined in the dataframe and the tests of simple effets are possible with a coding of the dataframe set to contr.treatment.

## Value

A list containing : a table of the clusters, or a multcomp object for the other multiple comparison procedures. Use the plot.clusterlm method to have a quick overview of the results.

## References

Maris, E., & Oostenveld, R. (2007). Nonparametric statistical testing of EEG-and MEG-data. Journal of neuroscience methods, 164(1), 177-190.

Smith, S. M., & Nichols, T. E. (2009). Threshold-free cluster enhancement: addressing problems of smoothing, threshold dependence and localisation in cluster inference. Neuroimage, 44(1), 83-98.

plot.clusterlm
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ## Cluster-mass for repeated measures ANOVA ## Warning : np argument must be greater (recommendation: np >= 5000) electrod_O1 <- clusterlm(attentionshifting_signal ~ visibility*emotion*direction + Error(id/(visibility*emotion*direction)), data = attentionshifting_design, np = 50) ## Results plot(electrod_O1) ## Results with labels on the x axis that represent seconds from time-locked event: plot(electrod_O1, nbbaselinepts = 200, nbptsperunit = 1024) ## Tables of clusters electrod_O1 ## Not run: ## Change the function of the aggregation ## Sum of squares of F statistics electrod_O1_sum <- clusterlm(attentionshifting_signal ~ visibility*emotion*direction + Error(id/(visibility*emotion*direction)), data = attentionshifting_design, aggr_FUN = function(x)sum(x^2)) ## Length of the cluster electrod_O1_length <- clusterlm(attentionshifting_signal ~ visibility*emotion*direction + Error(id/(visibility*emotion*direction)), data = attentionshifting_design, aggr_FUN = function(x)length(x)) ## All multiple comparisons procedures for repeated measures ANOVA ## Permutation method "Rde_kheradPajouh_renaud" full_electrod_O1 <- clusterlm(attentionshifting_signal ~ visibility*emotion*direction + Error(id/(visibility*emotion*direction)), data = attentionshifting_design, method = "Rde_kheradPajouh_renaud", multcomp = c("troendle", "tfce", "clustermass", "bonferroni", "holm", "benjamini_hochberg")) ## End(Not run)