This file contains hidden or 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(wordbankr) | |
| library(tidyverse) | |
| possess_data <- get_instrument_data(language = "English (American)", | |
| form = "WS", | |
| items = "item_687") # note that 687 is the s-possess item | |
| admin_data <- get_administration_data(language = "English (American)", | |
| form = "WS") | |
| left_join(possess_data, admin_data) %>% |
This file contains hidden or 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) | |
| n_sim <- 100 | |
| sims <- expand_grid(n_total = seq(50,500,25), | |
| i = 1:n_sim) %>% | |
| mutate(idx = 1:n()) %>% | |
| split(.$idx) %>% | |
| map_df(function (df) { | |
| cntl_sim <- tibble(choice = c(rbinom(n = df$n_total/2, size = 1, p = .68), | |
| rbinom(n = df$n_total/2, size = 1, p = .5)), | |
| condition = c(rep("social", df$n_total/2), |
This file contains hidden or 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(MASS) | |
| library(tidyverse) | |
| # from https://homeweb.unifr.ch/VanhoveJ/Pub/simulation_covariates.html | |
| # Define function | |
| # n <- 20 # observations per group | |
| # diff <- 0 # difference between groups | |
| # sd_y <- 3 # within-group sd of outcome (population-level) | |
| # rho_covars <- c(0.7, 0.3, 0) # correlation of control variables with outcome | |
| # in control group; add more coefficients to |
This file contains hidden or 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(brms) | |
| library(langcog) | |
| d <- tibble(subject = c(1, 1, 1, 1, 2, 2, 2, 2, | |
| 3, 3, 3, 3, 4, 4, 4, 4), | |
| response = c("E",NA,"A","error", | |
| "E","E","E","error", | |
| "A","A","E","error", | |
| "A","A","A","A"), |
This file contains hidden or 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
| # based on http://egap.org/methods-guides/10-things-know-about-covariate-adjustment | |
| library(MASS) # for mvrnorm() | |
| library(tidyverse) | |
| set.seed(1234567) | |
| num.reps = 1000 | |
| # True treatment effect is 0 for every unit | |
| adj.est = function(n, cov.matrix, treated) { |
This file contains hidden or 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
| iqs <- data_frame(iq = rnorm(mean = 100, sd = 15, n= 40), | |
| school = c(rep("Stanford",20), rep("Berkeley",20)), | |
| year = factor(rep(c(1950,1990),20))) | |
| summary(lm(iq ~ school * year, data = iqs)) | |
| summary(lm(scale(iq) ~ school * year, data = iqs)) | |
This file contains hidden or 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(lme4) | |
| library(here) | |
| library(tidyverse) | |
| d <- read_csv(here("processed_data/03_data_trial_main.csv")) %>% | |
| mutate(method = case_when( | |
| method == "singlescreen" ~ "Central fixation", | |
| method == "eyetracking" ~ "Eye tracking", | |
| method == "hpp" ~ "HPP", |
This file contains hidden or 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(ggthemes) | |
| n_trials <- c(2,4,8) | |
| p_anticipation <- seq(0,1,.1) | |
| n_subs <- c(12,24,36,48) | |
| n_sims <- 1000 | |
| d <- expand.grid(n_trials = n_trials, | |
| p_anticipation = p_anticipation, |
This file contains hidden or 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) | |
| # Nonexistence context, Nonexistence referent, apples? QUD | |
| nna <- tibble(ratio = c("ratio0", "ratio1", "ratio2", "ratio3"), | |
| probs = c(0.3323976330361966, 0.39954163105573637, 0.37453297805618113, 0.3323976330361966), | |
| context = "nonexistence context", | |
| referent = "nonexistence referent", | |
| qud = "apples?") | |
| naa <- tibble(ratio = c("ratio0", "ratio1", "ratio2", "ratio3"), |
This file contains hidden or 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) | |
| foo <- data_frame(time = c(1:5, 1:5), | |
| code = c(1,2,3,2,1,0,0,1,2,1), | |
| subid = c(rep(1,5), rep(2, 5))) | |
| foo %>% | |
| group_by(subid) %>% | |
| mutate(d_code = c(0,diff(code)), | |
| one_two_transition = code == 2 & d_code == 1, | |
| two_three_transition = code == 3 & d_code == 1) %>% |