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
require(ggplot2) | |
#Save downloaded Scopus data in your working directory | |
scopusdata<-read.csv("scopusPS2010_2015.csv") | |
plot1<-ggplot(scopusdata, aes(x=Cited.by)) + | |
geom_histogram(colour="#535353", fill="#84D5F0", binwidth=2) + | |
xlab("Number of Citations") + ylab("Number of Articles") + | |
ggtitle("Citation Data for Psychological Science 2011-2015") + | |
coord_cartesian(xlim = c(-5, 250)) |
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(reshape2) | |
library(mvtnorm) | |
library(ez) | |
#Install multtest# try http:// if https:// URLs are not supported | |
source("https://bioconductor.org/biocLite.R") | |
biocLite("multtest") | |
library(mutoss) #load multiple testing library for Holm function | |
#2x2x2 within design | |
N<-50 #sample size per group |
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
#Bayesian Power Analysis | |
if(!require(BayesFactor)){install.packages('BayesFactor')} | |
library(BayesFactor) | |
D<-0.0 #Set the true effect size | |
n<-50 #Set sample size of your study (number in each group) | |
nSim<-100000 #Set number of simulations (it takes a while, be patient) | |
rscaleBF<-sqrt(2)/2 #Set effect size of alternative hypothesis (default = sqrt(2)/2, or 0.707) | |
threshold<-3 #Set threshold for 'support' - e.g., 3, 10, or 30 |
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
if(!require(ggplot2)){install.packages('ggplot2')} | |
library(ggplot2) | |
if(!require(MBESS)){install.packages('MBESS')} | |
library(MBESS) | |
#Set color palette | |
cbbPalette<-c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") | |
N<-20 | |
#Set mean and SD |
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
if(!require(ggplot2)){install.packages('ggplot2')} | |
library(ggplot2) | |
n=20 #set sample size | |
nSims<-100000 #set number of simulations | |
x<-rnorm(n = n, mean = 100, sd = 15) #create sample from normal distribution | |
#95%CI | |
CIU<-mean(x)+qt(0.975, df = n-1)*sd(x)*sqrt(1/n) |
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
setwd("C:/Users/Daniel/Downloads/Gilbert, King, Pettigrew, Wilson 2016 replication files/variability analysis replication files/data") | |
load("many labs replication cis.RData") | |
## Drop the top rows which are statistics from pooling together all the replications | |
res <- lapply(res, function(x) x[-c(1:2),]) | |
res[[12]] <- res[[12]][-1,] | |
names(res[[16]])[3:5] <- names(res[[15]])[3:5] | |
## For each replicated study, get the number of the other replicated | |
## studies that were outside the CI |
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
df1<-1 | |
df2<-100 | |
critF<-qf(.95, df1=df1, df2=df2) #determine critical F-value | |
critT<-qt(.975, df2) #determine critical F-value | |
critF #critical F-value | |
critT^2 #Critical t squared is the same as critical F-value | |
critT #critical t-value | |
x=seq(0,10,length=10000) | |
maxy<-ifelse(max(df(x,df1,df2))==Inf,1, max(df(x,df1,df2))) #set maximum y axis |
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
if(!require(meta)){install.packages('meta')} | |
library(meta) | |
nSims <- 1000000 #number of simulated experiments | |
numberstudies<-4 # nSim/numberofstudies should be whole number | |
p <-numeric(nSims) #set up empty container for all simulated p-values | |
metapran <-numeric(nSims/numberstudies) #set up empty container for all simulated p-values for random effects MA | |
metapfix <-numeric(nSims/numberstudies) #set up empty container for all simulated p-values for fixed effects MA | |
heterog.p<-numeric(nSims/numberstudies) #set up empty container for test for heterogeneity | |
d <-numeric(nSims) #set up empty container for all simulated d's |
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
if(!require(ggplot2)){install.packages('ggplot2')} | |
library(ggplot2) | |
if(!require(pwr)){install.packages('pwr')} | |
library(pwr) | |
nSims <- 100000 #number of simulated experiments | |
M<-106 #Mean IQ score in the sample | |
n<-26 #set sample size | |
SD<-15 #SD of the simulated 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
if(!require(BayesFactor)){install.packages('BayesFactor')} | |
library(BayesFactor) | |
#to get emoticons for each test, set wait to 0.5 and showfaces to 1. | |
#When running large number of simulations, set wait to 0 and showfaces to 0. | |
options(scipen=20) #disable scientific notation for numbers | |
waitx<-0.5 #To see a small wait between individual trials, set a wait time to e.g., 0.5 | |
showfaces<-1 #Set to 0 if you do not want the faces, set to 1 if you want to see the faces | |
cohensd<-0.3 #set true effect size | |
n<-75 #sample size in each group |