# Creating a sample dataset
reversal_withdrawal <- data.frame(
phase = c(rep("baseline1", 6), rep("treatment1", 5), rep("baseline2", 5), rep("treatment2", 5)),
time = 1:21,
extbehavs = c(15, 10, 14, 17, 13, 12, 2, 1, 1, 0, 0, 9, 9, 11, 15, 20, 1, 0, 4, 0, 1)
)
reversal_withdrawal$synth <- sapply(reversal_withdrawal$time, function(x) {
stats::rpois(1, x)
})
reversal_withdrawal <- as.data.frame(reversal_withdrawal)
# Using the cross_lagged function
cl_result <- cross_lagged(reversal_withdrawal, .x = "time", .y = "synth")
Run the code above in your browser using DataLab