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
#------------------------------------------------------------------------------ | |
# generate data from a multivariate normal distribution with known | |
# correlations between values | |
mvrnorm <- function(n, nValues, meanValues, sdValues, corMatrix) { | |
Z <- matrix(rnorm(n * nValues), nValues, n) | |
t(meanValues + sdValues * t(chol(corMatrix)) %*% Z) | |
} | |
#------------------------------------------------------------------------------ | |
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
### plots of prior robustness check | |
# gif created from PNG plots using http://gifmaker.me/ | |
# clear R's memory | |
rm(list = ls()) | |
# load the Bayes factor package | |
library(BayesFactor) |
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(ggplot2) | |
library(emoGG) | |
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + | |
geom_emoji(emoji = "2744") + add_emoji(emoji = "26c4") |
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
#------------------------------------------------------------------------------ | |
### set up | |
# clear workspace | |
rm(list = ls()) | |
# set working directory | |
setwd("D:/Work/Blog_YouTube code/Blog/Olympic Medals") | |
# load relevant packages |
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
setwd("C:/Users/psa33/Dropbox/Work/Blog/gifs/increasingN") | |
binWidth <- 0.005 | |
# define parameter space | |
x <- seq(from = binWidth / 2, to = 1 - binWidth / 2, by = binWidth) | |
# what rate of fairness is the coin? | |
rate <- 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
#------------------------------------------------------------------------------ | |
rm(list = ls()) | |
set.seed(50) | |
# function for generating random draws from multivariate distribution | |
# n = number of draws; p = number of variables | |
# u = mean of each variable; s = SD of each variable | |
# corMat = correlation matrix | |
mvrnorm <- function(n, p, u, s, corMat) { |
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
#------------------------------------------------------------------------------ | |
### initial set up | |
rm(list = ls()) | |
# set working directory | |
setwd("D:/Work/Other/Blog_YouTube code/Blog/Bayesian Partial Correlation") | |
# load libraries | |
library(ppcor) | |
library(Hmisc) |
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(metafor) | |
library(dplyr) | |
# sample size per study | |
n <- 10 | |
# population effect size | |
true_d <- 0.2 | |
# generate studies |
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(rtdists) | |
set.seed(42) | |
# declare correct & error drift rate | |
correct_drift <- 2.4 | |
error_drift <- 1 - correct_drift | |
# generate RTs with the diffusion model | |
rt1 <- rLBA(500, A = 0.5, b = 1, t0 = 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
# https://nceas.github.io/oss-lessons/parallel-computing-in-r/parallel-computing-in-r.html | |
library(parallel) | |
library(foreach) | |
library(doParallel) | |
library(snow) | |
set.seed(42) | |
n_subs <- 100000 | |
n_trials <- 5000 |
OlderNewer