Skip to content

Instantly share code, notes, and snippets.

Richard Morey richarddmorey

Block or report user

Report or block richarddmorey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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)
@richarddmorey
richarddmorey / bf_inv.R
Created Oct 17, 2017
Inverse function of Bayes factor for t test
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){
@richarddmorey
richarddmorey / sample.eta2.R
Last active Oct 2, 2017
Sampling distribution of eta^2, omega^2-hat, and epsilon^2
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
@richarddmorey
richarddmorey / meta-normal.Rmd
Created Jul 4, 2017
Bayesian normal meta-analysis with descriptives
View meta-normal.Rmd
---
title: "Normal meta-analysis"
author: "Richard D. Morey"
date: "04/07/2017"
output: html_document
---
```{r}
# data here
@richarddmorey
richarddmorey / cov.R
Created Jul 1, 2017
covariance matrix
View cov.R
x = scan()
0.78
0.71
0.69
0.71
0.73
0.68
0.69
0.64
0.64
@richarddmorey
richarddmorey / _scatter.R
Last active May 29, 2017
APS2017 Presidential symposium slide 1
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")
@richarddmorey
richarddmorey / onetail_lmBF.R
Created Apr 5, 2017
One-tailed testing with lmBF
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
@richarddmorey
richarddmorey / delta_t.R
Last active Feb 27, 2017
posterior for delta given only t and N
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){
You can’t perform that action at this time.