View why_leave.R
## Richard D. Morey
## 3 Nov 2017
# Redirect plots to temp directory
# We just want the variables
wd = getwd()
setwd(tempdir())
source('https://osf.io/x73zq/download?version=1')
setwd(wd)
View bf_inv.R
## Given a (scaled Cauchy) Bayes factor for the null against the
## alternative (Rouder et al 2009), yields the t statistic
## that would yield it. The ... arguments are passed to
## the ttest.tstat function.
bf.inv = Vectorize(function(b10, ...){
fn = Vectorize(function(t,...){
BayesFactor::ttest.tstat(t,...)[["bf"]]
}, "t")
t0 = optimize(function(t0, ...){
View for_lakens.R
find.ncp = Vectorize(function(a=.05, b=.2, df=1){
cr = qchisq(1-a,df)
q = optimize(function(q){
(pchisq(cr,df,ncp=q/(1 - q)) - b)^2
},interval = c(0,1))$minimum
q / (1 - q)
},"b")
find.eb = Vectorize(function(a = 0.05, b = .2, df = 1){
View sample.eta2.R
## Explore the sampling distribution of eta^2, omega^2-hat, and epsilon^2
## Richard D. Morey
## Sept 30, 2017
## Settings
## Number of participants in group
N = 10
## Number of groups
J = 3
View stereograms.csv
ID fuseTime condition logFuseTime
1 47.20001 NV 3.85439410445589
2 21.99998 NV 3.09104154426699
3 20.39999 NV 3.01553441065397
4 19.70001 NV 2.98061914335803
5 17.4 NV 2.85647020622048
6 14.7 NV 2.68784749378469
7 13.39999 NV 2.59525396068793
8 13 NV 2.56494935746154
9 12.3 NV 2.50959926237837
View meta-normal.Rmd
title author date output
Normal meta-analysis
Richard D. Morey
04/07/2017
html_document
# data here
View cov.R
x = scan()
0.78
0.71
0.69
0.71
0.73
0.68
0.69
0.64
0.64
View _scatter.R
d = read.csv("https://gist.githubusercontent.com/richarddmorey/f7c3ed9fe3f9f1fc0520f332b4a8efd7/raw/900d75f765a086dba65a316504c926da1c1e894a/golf.csv")
plot(d$score, d$size, xlab = "Course score", ylab = "Perceived size", axes = FALSE, ylim = c(0,9), xlim = c(60,140), pch = 19)
axis(2, at = 1:9, las = 1)
axis(1)
abline(lm(size~score, data = d))
cor(d$size, d$score, method = "spearman")
# edge of significance
cor.test(d$size, d$score, method = "spearman")
View onetail_lmBF.R
## For the singer dataset
library(lattice)
data(singer)
## Get data ready (recode to two factors)
singer$female = factor(with(singer, grepl("S",voice.part) | grepl("A",voice.part)))
singer$high = factor(with(singer, grepl("S",voice.part) | grepl("T",voice.part)))
## We will test the hypothesis that the main effect
## of "high voice" is such that high voiced singers are shorter
View delta_t.R
### Data
t = 2
N = 20
rscale = sqrt(2)/2
### Begin utility functions
posterior = Vectorize(function(delta, t, N1, N2 = NULL, rscale = sqrt(2)/2, log = FALSE){