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(rscopus) | |
library(tidyverse) | |
library(igraph) | |
library(GGally) | |
faculty <- read_csv("faculty.csv") | |
faculty$au_id <- NA | |
for (i in 1:nrow(faculty)) { | |
print(i) |
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(BFpack) | |
# function to simulate bayes factors in Kat's experiments | |
# takes: | |
# - n subjects in each condition | |
# - p1 for first condition success probability | |
# - p2 for second condition success probability | |
sim_bfs <- function(n, p1, p2) { | |
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) | |
# let's define hunter and ames functions as a family of quadratic functions | |
# where y = beta_1 * x + beta_2 * x^2 | |
# and beta_1 < 0 and beta_2 > 0 | |
t <- seq(0, 10, .1) | |
sim <- expand_grid(b1 = seq(-1, 0, .2), | |
b2 = seq(0, .1, .02), |
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(BFpack) | |
n <- 12 | |
kat_data <- tibble(condition = c(rep("reliable", n), | |
rep("unreliable", n)), | |
harder = c(rbernoulli(n, p = .8), | |
rbernoulli(n, p = .3))) | |
kat_data %>% group_by(condition) %>% summarise(mean_harder = mean(harder)) |
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) | |
probs <- c(.6, .8) | |
df <- expand_grid(subid = 1:10, | |
condition = 1:2, | |
trial_num = 1:12) %>% | |
group_by(condition) %>% | |
mutate(correct = rbinom(n = n(), size = 1, prob = probs[condition][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
library(tidyverse) | |
d <- read_csv("Replication_Race_For_R_012519.csv") | |
correct <- tribble(~name, ~correct_value, ~longname, | |
"SocialMotherLanguage", 0, "prefer individuals who speak their mother’s primary language", | |
"SocialGenderGroup", 24, "start identifying as members of a particular gender group", | |
"SocialFaceNonface", 0, "can tell the difference between faces and things", | |
"SocialFat", 36, "begin associating being fat with negative traits", | |
"RaceRace-Status", 47, "associating particular racial groups with status", | |
"RaceLowStatusNegative", 36, "associate low-status racial groups with negative traits", |
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
tibble(y = c(1,2,3,4), | |
x = c("E","C","E","C"), | |
subid = c(1,1,2,2)) %>% | |
group_by(subid) %>% | |
do(broom::tidy(lm(y ~ x, data = .))) %>% | |
group_by(term) %>% | |
do(broom::tidy(lm(estimate ~ 1, data = .))) |
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) | |
trials_per_kid <- 12 | |
sim_data <- function (n) { | |
d <- expand.grid(subid = 1:n, | |
condition = c("pred","unpred","consistent")) %>% | |
rowwise %>% | |
mutate(correct = mean(rbinom(n = trials_per_kid, |
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(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 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), |