View libraries and data used in these notes
library(tidyverse)
library(tidymodels)Dr. Alexander Fisher
Read the following article: Greenwood et al. (2020)
In particular, as you read, try to answer the following:
10:00
Read Simmons, Nelson, and Simonsohn (2011) from the abstract through “Study 1” and read the results reported in Table 1.
Read the code below, and figure out what it’s doing. Chat with your neighbor. Explain what the result means.
set.seed(221)
total = 0
N = 1000
for (j in 1:N) {
y = rnorm(30)
x1 = runif(30)
x2 = rnorm(30)
model1 = lm(y ~ x1 + x2)
model2 = lm(y ~ x1)
model3 = lm(y ~ x2)
model4 = lm(y ~ x1 * x2)
model5 = lm(y ~ 0 + x1)
model6 = lm(y ~ 0 + x2)
model7 = lm(y ~ 1)
hackable = 0
for (i in 1:7) {
m = get(paste0("model", i))
indicator = 0
if(sum(tidy(m)$p.value < 0.01) > 0) {
indicator = 1
}
hackable = hackable + indicator
}
total = total + hackable
}
total / N[1] 0.607