Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time cluster'-type analysis using a 1-sample t-test #65

Open
mmb951 opened this issue Jun 7, 2018 · 5 comments
Open

time cluster'-type analysis using a 1-sample t-test #65

mmb951 opened this issue Jun 7, 2018 · 5 comments

Comments

@mmb951
Copy link

mmb951 commented Jun 7, 2018

Hi

First of all, thanks for the useful EytrackingR website. I would like to run a 'time cluster'-type analysis using a 1-sample t-test to test when the bias to a target AOI significantly exceeds chance (in our experiment .25; with time as a continuous variable in 50ms bins). Is this possible in the current functions, please?

Many thanks
Mahsa

@respatte
Copy link

Hi,

I agree that this feature would be really useful. In the meantime, I have a little work-around that I'm pretty confidence isn't statistically bad. The idea is to trick eyetrackingR by creating a chance-level dataset to compare the actual data to:

response_time <- response_window_clean %>%
  mutate(Chance = F) %>% # This is the actual data, not the chance level
  make_time_sequence_data(time_bin_size = 100,
                          aois = "YourAOI",
                          predictor_columns="Chance",
                          summarize_by = "ParticipantName")

# Create the chance-level data
response_time.chance <-  response_time %>%
  mutate(Chance = T, # This is the chance data
         Participant = paste0("Chance", Participant),
         # This is so eyetrackingR is okay with within_part = F
         Prop = .5) # Change with your actual chance level
  # If you use a DV other than Prop in your test, just change this DV instead

# Merging the data and chance datasets together
response_window.chance_test <- rbind(response_window,
                                     response_window.chance) %>%
  mutate_at("Chance", parse_factor, levels = NULL) # Just in case

After that, you can just run the analysis using Chance as a predictor column:

# Determine threshold based on alpha = .05 two-tailed
num_sub = length(unique((response_window.chance_test$ParticipantName)))
threshold_t = qt(p = 1 - .05/2,
                 df = num_sub-1)

# Determine clusters
df_timeclust <- response_window.chance_test %>%
  make_time_cluster_data(predictor_column = "Chance",
                         aoi = "YourAOI",
                         test = "t.test",
                         threshold = threshold_t)

# Run analysis
clust_analysis <-  analyze_time_clusters(df_timeclust,
                                         within_subj = F,
                                         parallel = T)

@mmb951
Copy link
Author

mmb951 commented Jul 2, 2018

@respatte Great, I will try that. Thanks a lot for your help

@sambfloyd
Copy link

hi! this is great, thanks @respatte . My issue is that the cluster analysis does not provide a t or p statistic as far as I can tell. The function analyze_time_bins produces these but I don't think your method will work with analyze_time_bins. Any recommendations?

@respatte
Copy link

@sambfloyd I didn't test it but I don't see why this workaround wouldn't work with analyze_time_bins, have you tried it?
I'm guessing what you want is a t-statistic for each time bin, whether it reaches the defined threshold or not? In that case you would need to use analyse_time_bins indeed, but analyze_time_clusters does give you the summed t statistic for each cluster.

@sambfloyd
Copy link

@respatte sorry for not updating, I did exactly that and forgot to post -- it works great.

The only minor issue I have (with both clusters and bins) is the mutate_at line of code- it runs but it seems to recode the Chance variable weirdly-- when I look at the levels it says character(0) instead of NULL (which does work for the analysis). But I just run it without that since chance is comes out as having NULL levels before that line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants