Skip to content

Adding Top Level Function to use calculateDelta in factorial designs (WIP)#8

Draft
lboel wants to merge 1 commit intoigmmgi:masterfrom
lboel:top_level_function_calculateDelta_factorial
Draft

Adding Top Level Function to use calculateDelta in factorial designs (WIP)#8
lboel wants to merge 1 commit intoigmmgi:masterfrom
lboel:top_level_function_calculateDelta_factorial

Conversation

@lboel
Copy link

@lboel lboel commented Apr 19, 2023

A small proposal for a top level function to use calculateDelta in a factorial design.

dat <- createDF(nSubjects = 1, nTrl = 10000, design = list("Comp" = c("comp", "incomp")))

dat <- addDataDF(dat,
                  RT = list("Comp_comp"   = c(500, 80, 100),
                           "Comp_incomp" = c(600, 80, 140)))

dat$additionalFactor <- sample(c("Test","Experiment"),nrow(dat),replace = T)

delta <- calculateDeltaFactorialLong(dat, factorNames = c("additionalFactor"),
                                     nDelta = 19,
                                     tDelta = 1,
                                     columns = c("Subject", "Comp", "RT"),
                                     compCoding = c("comp", "incomp"),
                                     quantileType = 5)`

Would output something like this:
image

This function was developed based on an idea by https://github.com/rubenellinghaus.

At the moment this is only a draft and the main contributors should decide whether I should proceed here and this is a good addition to the package.

Best,

Luke

@lboel
Copy link
Author

lboel commented Apr 19, 2023

@igmmgi Ruben uses this approach for his experiment designs. So I build a function based on his approach.

@igmmgi
Copy link
Owner

igmmgi commented May 3, 2023

Would something like this work using group_modify from dplyr? This keeps the same tibble columns and just adds in the additionalFactor.

library(dplyr)
dat <- createDF(nSubjects = 1, nTrl = 10000, design = list("Comp" = c("comp", "incomp")))

dat <- addDataDF(dat,
                 RT = list("Comp_comp"   = c(500, 80, 100),
                           "Comp_incomp" = c(600, 80, 140)))

dat$additionalFactor <- sample(c("Test","Experiment"),nrow(dat),replace = T)

delta_group <- dat %>%
  group_by(additionalFactor) %>%
  group_modify(~ calculateDelta(.,  
                             nDelta = 19, 
                             tDelta = 1,
                             columns = c("Subject", "Comp", "RT"),
                             compCoding = c("comp", "incomp"),
                             quantileType = 5))

@rubenellinghaus
Copy link

Ians solution works well for me. Just adding

%>%
dplyr::group_by(Bin, additionalFactor) %>%
dplyr::summarise(mean_Bin = mean(meanBin), mean_effect = mean(Effect))

gives the tibble I want for ggplot.

Thanks a lot, @igmmgi, this will save me a lot of time and nerves. I was wondering whether the solution might be good to add to the documentation/tutorial, as users without strong programming background might not come up with such straightforward solution. This is just an intuition and up to the developers of course.

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

Successfully merging this pull request may close these issues.

3 participants