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(gamlss) | |
| d <- readxl::read_excel("sample_data.xlsx") | |
| # model | |
| max_vocab <- max(d$`Vocabulary production`) | |
| # transformation to 0-1 for beta model | |
| # note that beta data cannot be exactly 0 or 1, it may be necessary to add/subtract .001 for data including 0s and 1s |
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
| # delta rule formula | |
| # (i-o) o (1-o) | |
| library(tidyverse) | |
| d <- expand_grid(i = seq(0.05,.95,.05), | |
| o = seq(0.05,.95,.05)) |> | |
| mutate(last_part = o * (1-o), | |
| first_part = abs(i-o), | |
| delta = abs((i-o) * o * (1-o)), | |
| divergence = i * log(i/o)) |
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(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 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(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 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) | |
| # 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 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(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 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) | |
| 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 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) | |
| 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 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
| 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 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(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, |