Creating simulated data with 2 blocks in randomized order

0

For the power analysis for my Master's Thesis I need to create a simulated dataset according to my study design. I had this code mirroring the planned design of my study, but now my supervisor told me to change some aspects.

set.seed(1234)

n_participants <- 50
n_stories <- 8
  simulated_data <- data.frame(
    subj = rep(1:n_participants, each = n_stories),
    story = rep(1:n_stories, times = n_participants),
    group = rep(sample(c(-1, 1), size = n_participants, replace = TRUE), each = n_stories),
    target = rep(sample(c(-1, 1), size = n_participants * n_stories, replace = TRUE), each = 1),
    action = rep(sample(c(-1, 1), size = n_participants * n_stories, replace = TRUE), each = 1),
    interc = rep(b0,n_participants * n_stories)
  )

First of all, for target, I will show the participants 8 stories, but in 2 blocks of 4. I need Block A with 4x -1 and Block B with 4x +1, and the order of these blocks is randomized for every participant.

Moreover, I need to make sure that each subject sees each value of action exactly 4 times. So each subject sees 4x -1 and 4 times 1, but in a randomized order. I am not an R pro and therefore I seem to not be able to figure it out. Can you maybe help me with this?

Question: What is B0 n this line?

interc = rep(b0,n_participants * n_stories)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.