This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# Set the effect size | |
eff_size <- 0.2 | |
# Function to simulate data, run regression, and check if individual predictors are significant | |
simulate_and_regress <- function(n) { | |
data <- tibble( | |
a = rnorm(n), | |
b = rnorm(n), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(faux) | |
library(lme4) | |
library(afex) | |
options(dplyr.summarise.inform = FALSE) | |
set.seed(123) | |
sim_data <- function(n_subj, n_trials){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(flankr) | |
# get example data from flankr | |
# ONLY SHOWING FOR CONGRUENT DATA. | |
d <- flankr::exampleData %>% | |
filter(congruency == "congruent") | |
# how many subjects? | |
n_subjects <- length(unique(d$subject)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load packages ----------------------------------------------------------- | |
library(tidyverse) | |
library(brms) | |
library(tidybayes) | |
library(bayesplot) | |
library(emmeans) | |
library(bayestestR) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(brms) | |
library(tidyverse) | |
set.seed(123) | |
# generate some subject-averaged data | |
n_subjects <- 100 | |
data <- tibble( | |
id = 1:n_subjects, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(faux) | |
library(lme4) | |
library(afex) | |
options(dplyr.summarise.inform = FALSE) | |
set.seed(123) | |
sim_data <- function(n_subj, n_trials){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(BayesFactor) | |
# set seed for reproducibility | |
set.seed(234) | |
# define population-level parameters | |
p_text_yes <- 0.5 | |
p_video_yes <- 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(Superpower) | |
# set means & standard deviations for idealised data | |
# (note experiment 1 data comes from the pilot experiment) | |
exp_1_means <- c(1334, 1594, 1588, 1725) | |
exp_1_sds <- c(308, 295, 338, 343) | |
exp_2_means <- c(1030, 1080, 1120, 1150) | |
exp_2_sds <- c(200, 200, 200, 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gaussian kernel function | |
gaussian_kernel <- function(u){ | |
(1 / sqrt(2 * pi)) * exp(-0.5 * u ^ 2) | |
} | |
# kernel density estimate function | |
kde <- function(n, data, x_limit, y_limit, h_x, h_y){ | |
x <- seq(from = x_limit[1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod_1 <- brm(value ~ questionnaire * condition, | |
data = idealised_data, | |
seed = 42, | |
cores = 4) | |
mod_2 <- brm(value ~ questionnaire + condition, | |
data = idealised_data, | |
seed = 42, | |
cores = 4) |
NewerOlder