0

I have a large dataset with EEG data where I have several columns: channel (58), subject (24), condition (3), trial_nb (with the number of each trial), and then I have individual columns for each data point from -200 to 1100ms where I have the data of each amplitude voltage. Data looks like this (with an example of 1 of my 3 conditions called Congr, and 2 out of the 58 channels) :


channel subject condition trial_nb -200 -199 -198 ...
AF3 01 Congr 1 -2.817600 -3.068800 -3.256800 ...
AF4 01 Congr 1 1.679700 1.628300 1.582800 ...
... ... ... ... ... ... ... ...

I want to run a permutations test implementing linear mixed models. The function in R is perm.lmer (). The example given in the package website is the following:

(Fz ~ Deviant * Session + (Deviant * Session | Subject),
data=MMN[MMN$Time > 150 & MMN$Time < 250,])

Nevertheless, this only applies to one of the channels in the data, called Fz and I want to run it over all the electrodes. I was able to run a permu.test based on the example given in the package that looks like this:

perms <- permu.test(cbind(AF3, AF4, C1, C2, C3, C4, C5, C6, CP1, CP2, CP3, CP4, CP5, CP6, CPz, Cz, F1, F2, F3, F4, F5, F6, F7, F8, FC1, FC2, FC3, FC4, FC5, FC6,FCz, FP1, FP2, FPz, Fz, M1, M2, O1, O2, Oz, P1, P2, P3, P4, P5, P6, P7, P8, PO3, PO4, PO7, PO8, POz, Pz, T7, T8, TP7, TP8) ~ condition | time, data=df_perm_)

I tried to do merge both permutation examples to do the perm.lmer but it does not work. I wrote this:

perms <- perm.lmer(cbind(AF3, AF4, C1, C2, C3, C4, C5, C6, CP1, CP2, CP3, CP4, CP5, CP6, CPz, Cz, F1, F2, F3, F4, F5, F6, F7, F8, FC1, FC2, FC3, FC4, FC5, FC6, FCz, FP1, FP2, FPz, Fz, M1, M2, O1, O2, Oz, P1, P2, P3, P4, P5, P6, P7, P8, PO3, PO4, PO7, PO8, POz, Pz, T7, T8, TP7, TP8) ~ condition + (condition | subject) | time, data=df_perm_).

The error that I get is:

Error: Must subset rows with a valid subscript vector. i Logical subscripts must match the size of the indexed input. x Input has size 3800 but subscript ix has size 0.

I think that the problem is that I do not know how to include the subjects in the loop to create a df for the permutations for which I convert the df into a format longer.

I hope I explained my problem correctly! Thanks in advance for your help!

vimuth
  • 5,064
  • 33
  • 79
  • 116

0 Answers0