Instantly share code, notes, and snippets.

Richard Moreyricharddmorey

• Sort options
Last active Nov 29, 2017
example for shinyjs
View index.Rmd
 --- runtime: shiny --- ```{r echo=FALSE, message=FALSE, warning=FALSE} require(shinyjs) useShinyjs(rmd=TRUE) observe({ updateTextInput(session, 'ID', value = "Updated.")
Created Nov 3, 2017
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)
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, ...){
Last active Oct 15, 2017
For Lakens
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){
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
Created Sep 6, 2017
Frisby and Clatworthy (1975) stereogram data (from http://lib.stat.cmu.edu/DASL/Stories/FusionTime.html)
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
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
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
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")
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
You can’t perform that action at this time.