eyetrackingR
eyetrackingR copied to clipboard
Analyse time clusters
Hello Eyetracking R,
I am having some problems analysing time clusters. I get the following error in the script that had worked a couple days ago: Error in .subset2(x, i, exact = exact) : recursive indexing failed at level 2
I have recently updated Eyetracking R, and other necessary packages such as Dplyr. Since having the problem, I've gone about updating every package just in case, but to no avail.
I had had a similar problem before, but it had worked out when I downgraded Dplyr (which I believe cannot do now, because the new version of Eyetracking R requires the new version of Dplyr).
Any ideas what it may be caused by?
Thank you, Monica
Re-hello EyetrackingR,
Update that might help with figuring out the source of the problem: I just ran analyse time clusters on the data set provided with eyetrackingR and I got the following error - Error in *tmp*
[[jj]] : subscript out of bounds
Thanks again, Monica
Hi everyone,
I'm having the same issue so I'm just going to add it here rather than open a new one. There are a couple issues with analyze_time_clusters
:
- treatment-coded variables can't be used with
within_subj = F
inanalyze_time_clusters
as thetreatment_level
argument isn't passed frommake_time_cluster_data
intoanalyze_time_clusters
:
## Determine clusters
LT.time_cluster_tail <- make_time_cluster_data(LT.time_course_tail,
predictor_column = "Condition",
treatment_level = "No Label",
aoi = "Tail",
test = "lmer",
threshold = 1.5,
formula = ArcSin ~ Condition +
(1 | Participant) +
(1 | Stimulus))
## Run analysis
LT.time_cluster_tail.analysis <- analyze_time_clusters(LT.time_cluster_tail,
formula = ArcSin ~ Condition +
(1 | Participant) +
(1 | Stimulus),
within_subj = F,
parallel = T,
samples = 200)
# Error in get_resampled_sum_stat_btwn(data, rows_of_participants, attrs, :
# task 1 failed - "
# The term 'Condition' was not found in your model.
# This can happen if your predictor is treatment-coded, in which case you should
# specify the `treatment_level` argument.
# For example, if 'Target' is treatment coded, then it becomes 'TargetInanimate'
# in the model, and you should set `treatment_level = 'Inanimate'`.
# The terms in the model were: '(Intercept)', 'ConditionNo Label'"
- directly supplying the treatment level in the
predictor_column
name (inmake_time_cluster_data
) raises an error when runninganalyze_time_clusters
(different error depending on the value given towithin_subj
):
## Determine clusters
LT.time_cluster_tail <- make_time_cluster_data(LT.time_course_tail,
predictor_column = "ConditionNo Label",
aoi = "Tail",
test = "lmer",
threshold = 1.5,
formula = ArcSin ~ Condition +
(1 | Participant) +
(1 | Stimulus))
## Run analysis with within_subj = T
LT.time_cluster_tail.analysis <- analyze_time_clusters(LT.time_cluster_tail,
formula = ArcSin ~ Condition +
(1 | Participant) +
(1 | Stimulus),
within_subj = T,
parallel = T,
samples = 200)
# Error in analyze_time_clusters.time_cluster_data(LT.time_cluster_tail, :
# The column 'ConditionNo Label' not found in your data.
## Run analysis with within_subj = F
LT.time_cluster_tail.analysis <- analyze_time_clusters(LT.time_cluster_tail,
formula = ArcSin ~ Condition +
(1 | Participant) +
(1 | Stimulus),
within_subj = F,
parallel = T)
# Error in get_resampled_sum_stat_btwn(data, rows_of_participants, attrs, :
# task 1 failed - "subscript out of bounds"
I'm not totally sure I understand the use of within_subj
however, so that might be the issue. In my experiment, each participant is assigned to one of two conditions, and so Condition
should be a between-subject factor, hence why I want to use within_subj = F
; am I wrong?
If you want my data to run the code on it, you can find it on my experiment's GitHub repository. You need to open the stats/InfantsAnalysis.R
file, run the blocks LIBRARY IMPORTS
and GATHER DATA
, then in the block LOOKING TIME ANALYSIS: TIME COURSE
you can run the DATA PREPARATION
lines and finally play with the code starting line 160.
I also encountered this issue and found that the problem had to do with specifying the make_time_sequence_data function. In my case, both "condition" and "participant" were wrongly included in the "summarize_by" argument. Moving "condition" to the "predictor_columns" argument cleared up the issue for me. Hope this helps you too!
Example in code:
WRONG:
timecourse <- make_time_sequence_data(df,
time_bin_size = 50,
aois = c("AOI1", "AOI2", "AOI3", "AOI4"),
predictor_columns = c("Sex"),
summarize_by = c("Participant", "Condition"))
CORRECT: timecourse <- make_time_sequence_data(df, time_bin_size = 50, aois = c("AOI1", "AOI2", "AOI3", "AOI4"), predictor_columns = c("Sex", "Condition"), summarize_by = c("Participant"))