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(MBESS) | |
library(pwr) | |
nSims <- 100000 #number of simulated experiments | |
p <-numeric(nSims) #set up empty container for all simulated p-values | |
obs_pwr <-numeric(nSims) #set up empty container | |
t <-numeric(nSims) #set up empty container | |
d_all<-numeric(nSims) | |
N<-33 #number of participants |
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) | |
g <- escalc( | |
measure = "SMD", | |
n1i = 43, # sample size in group 1 is 50 | |
m1i = 1.3, # observed mean in group 1 is 5.6 | |
sd1i = 1, # observed standard deviation in group 1 is 1.2 | |
n2i = 43, # sample size in group 2 is 53 | |
m2i = 1, # observed mean in group 1 is 4.9 | |
sd2i = 1 |
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
require(car) #Car package required for Levene's test | |
n1<-38 #size condition x | |
n2<-22 #size condition y | |
sd1<-1.11 #sd condition x | |
sd2<-1.84 #sd condition y | |
m1<-0 | |
m2<-0 | |
trueD<-(m2-m1)/(sqrt((((n1 - 1)*((sd1^2))) + (n2 - 1)*((sd2^2)))/((n1+n2)-2))) | |
trueD |
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 settings---- | |
# # # # # # # # # # # | |
if(!require(ggplot2)){install.packages('ggplot2')} | |
library(ggplot2) | |
if(!require(MBESS)){install.packages('MBESS')} | |
library(MBESS) | |
if(!require(pwr)){install.packages('pwr')} | |
library(pwr) | |
if(!require(meta)){install.packages('meta')} |
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
#Script based on Carter & McCullough (2014) doi: 10.3389/fpsyg.2014.00823 | |
#Load Libraries | |
library(meta) | |
library(metafor) | |
#Insert effect sizes and sample sizes | |
es.d<-c(0.38,0.41,-0.14,0.63,0.22) | |
n1<-c(75,48,22,18,60) | |
n2<-c(75,52,21,20,55) |
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(segHT) | |
library(rpact) | |
looks <- 3 | |
n_seg <- 50 | |
alpha_level <- 0.05 | |
true_d <- 0.5 # can not enter 0, segmented_hyp_test_outcomes gives error | |
############################### | |
# Segmented procedure ---- |
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
--- | |
title: "Power Analysis for Interactions" | |
author: "Daniel Lakens" | |
date: "28-3-2020" | |
output: | |
html_document: default | |
pdf_document: default | |
word_document: default | |
editor_options: | |
chunk_output_type: console |
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
n<-2000 #total number of datapoints (per condition) you are willing to collect after initial 10 | |
D<-0.0 #True effect size (Keep SD below to 1, otherwise, this is just mean dif, not d) | |
SD<-1 #Set True standard deviation. | |
p<-numeric(n) #store p-values | |
x<-numeric(n) #store x-values | |
y<-numeric(n) #store y-values | |
n<-n+10 #script calculates p-values after 10 people in each condition, so add 10 to number of datapoints |
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
# Scienceverse Sim | |
# install scienceverse | |
# devtools::install_github("scienceverse/scienceverse") | |
library(scienceverse) | |
library(faux) | |
set.seed(2) # set.seed(2) is a random draw where H1 is corroborated. |
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
# Scienceverse Sim | |
# install scienceverse | |
# devtools::install_github("scienceverse/scienceverse") | |
library(scienceverse) | |
library(faux) | |
set.seed(2) # set.seed(2) is a random draw where H1 is corroborated. |
NewerOlder