Compute the cluster-mass test for longitudinal linear model.

clusterlm(
  formula,
  data = NULL,
  np = 5000,
  method = NULL,
  type = "permutation",
  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 independent 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.

type

A character string to specify the type of transformations: "permutation" and "signflip" are available. Is overridden if P is given. See help from Pmat.

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", "minP" and "benjamini_hochberg".

...

Futher arguments, see details.

Value

A clusterlm object. Use the plot.clusterlm or summary.clusterlm method to see results of the tests.

Details

The random effects model is only available 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 reproducibility 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 dimensional 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.

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.

See also

Author

jaromil.frossard@unige.ch

Examples


## 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)
#> Warning: The number of permutations is below 2000, p-values might be unreliable.

## 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
#> Effect: visibility.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1   142 142     4.634852     0.50
#> 2   332 462  3559.149739     0.02
#> 3   499 514    85.019645     0.38
#> 4   596 632   234.877913     0.28
#> 5   711 738   191.576178     0.32
#> 
#> 
#> Effect: emotion.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1   115 133      120.625     0.22
#> 
#> 
#> Effect: direction.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1   387 401     89.29120     0.32
#> 2   427 435     43.15493     0.42
#> 3   697 716    117.22493     0.32
#> 
#> 
#> Effect: visibility:emotion.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1    99 112    125.64784     0.36
#> 2   494 504     58.91771     0.58
#> 
#> 
#> Effect: visibility:direction.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1   123 138    109.82819     0.24
#> 2   198 213     88.58742     0.34
#> 3   238 254     89.59733     0.34
#> 4   299 302     18.61131     0.40
#> 5   357 396    268.04807     0.12
#> 6   569 606    279.00621     0.10
#> 7   782 786     23.57752     0.40
#> 8   797 809     67.14642     0.36
#> 
#> 
#> Effect: emotion:direction.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1     7  26    126.98833     0.36
#> 2    53  64     78.54869     0.44
#> 3   247 262    127.82364     0.36
#> 4   388 398     58.70748     0.46
#> 5   540 558    100.14845     0.44
#> 
#> 
#> Effect: visibility:emotion:direction.
#> Alternative Hypothesis: two.sided.
#> Statistic: fisher(1, 14).
#> Resampling Method: Rd_kheradPajouh_renaud.
#> Type of Resampling: permutation.
#> Number of Dependant Variables: 819.
#> Number of Resamples: 50.
#> Multiple Comparisons Procedure: clustermass.
#> Threshold: 4.60011.
#> Mass Function: the sum.
#> Table of clusters.
#> 
#>   start end cluster mass P(>mass)
#> 1   189 197     50.90966     0.56
#> 2   242 251     50.40560     0.56
#> 
#> 

if (FALSE) {
## 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"))
}