Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanherzog committed May 11, 2023
0 parents commit f8d94e8
Show file tree
Hide file tree
Showing 53 changed files with 11,467 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This makes sure that R loads the workflowr package
## automatically, everytime the project is loaded
if (requireNamespace("workflowr", quietly = TRUE)) {
message("Loading .Rprofile for the current workflowr project")
library("workflowr")
} else {
message("workflowr package not installed, please run install.packages(\"workflowr\") to use the workflowr functions")
}
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Classify R Markdown files as R code for GitHub language statistics
# https://github.com/github/linguist#overrides
*.[Rr]md linguist-language=R
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
.DS_Store
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public
only:
- main
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Metacognitive accuracy in detecting political misinformation

Reanalysis of [Garrett & Bond (2021)](https://www.science.org/doi/10.1126/sciadv.abf1234) exploring citizens' metacognitive accuracy in detecting political misinformation.
40 changes: 40 additions & 0 deletions _workflowr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
### workflowr management


# project files
# (in their order of processing)
files <- c("analysis/index.Rmd",
"analysis/make_data.Rmd",
"analysis/basic_descriptives.Rmd",
"analysis/basic_measures.Rmd",
"analysis/H1_overall_insight.Rmd",
"analysis/H2_political_antecedents.Rmd",
"analysis/H3_predictors.Rmd",
"analysis/robustness_checks.Rmd")


# Building the project website
wflow_build(files = files,
verbose = TRUE,
republish = TRUE,
update = TRUE,
delete_cache = TRUE,
dry_run = FALSE)


wflow_use_gitlab(username = "ai_society",
repository = "confidence-and-misinformation",
domain = "arc-git.mpib-berlin.mpg.de")


# Publishing/updating the project website
wflow_publish(
files = files,
republish = TRUE,
delete_cache = TRUE,
dry_run = FALSE
)


wflow_git_push()

8 changes: 8 additions & 0 deletions _workflowr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# workflowr options
# Version 1.6.2

# The seed to use for random number generation. See ?set.seed for details.
seed: 20210920
# The working directory to build the R Markdown files. The path is relative to
# _workflowr.yml. See ?rmarkdown::render for details.
knit_root_dir: "."
122 changes: 122 additions & 0 deletions analysis/H1_overall_insight.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
title: "Overall insight into the accuracy of one’s truth judgments"
site: workflowr::wflow_site
output:
workflowr::wflow_html:
code_folding: hide
number_sections: yes
toc: yes
toc_depth: 3
editor_options:
chunk_output_type: console
---



# Setup

```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = TRUE,
cache = FALSE
)

```



# Source `dependencies.R`

```{r dependencies, message=FALSE, code=readr::read_lines(here::here("code/_dependencies.R"))}
source(here::here("code/_dependencies.R"))

```



# Load data

```{r load_data}
metad_group_all_participants_mcmc <- read_rds(here::here("output/models/group/metad_group_all_participants_mcmc.rds"))

metad_group <- read_rds(here::here("output/models/group/metad_group.rds"))


metad_group_all_participants <- metad_group %>%
filter(name == "all participants")


```



# H1.1 / H1.2: Metacognitive ideal hypothesis / Domain comparison hypothesis
Hypothesis (H1.1): Metacognitive efficiency for political statements is lower than the
theoretically optimal metacognitive efficiency of Mratio = 1
(see p.5 of preregistration:
https://osf.io/veja6/files/osfstorage/614c91e915e9a4005d9239cf).

Hypothesis (H1.2): Metacognitive efficiency for political statements is lower than for
non-politicized domains such as biology and physics (Mratio = 0.99; Fischer et al.,
2019) (see p.5 of preregistration:
https://osf.io/veja6/files/osfstorage/614c91e915e9a4005d9239cf).

```{r overall_insight}
# compare 95% CI and ROPE (i.e., 0.9 - 1.1)
mratio <- metad_group_all_participants_mcmc[[1]] %>%
filter(Parameter == "mu_logMratio") %>%
mutate(exp_value = exp(value))

below_rope <- rope(mratio$exp_value, c(-100 , 0.9), ci = 1)
below_rope <- below_rope$ROPE_Percentage * 100

within_rope <- rope(mratio$exp_value, c(0.9, 1.1), ci = 1)
within_rope <- within_rope$ROPE_Percentage * 100

above_rope <- rope(mratio$exp_value, c(1.1, 100), ci = 1)
above_rope <- above_rope$ROPE_Percentage * 100

# plot trace mcmc
traceplot(metad_group_all_participants_mcmc[[4]])

# figure posterior distribution of Mratio for all participants
fig_mcmc <- metad_group_all_participants_mcmc[[1]] %>%
filter(Parameter == "mu_logMratio") %>%
ggplot(aes(exp(value))) +
geom_histogram(
binwidth = 0.005,
fill = "blue",
colour = "grey",
alpha = 0.5
) +
geom_vline(
xintercept = metad_group_all_participants$Mratio_g,
linetype = "dashed",
size = 1.5
) +
geom_segment(aes(
x = metad_group_all_participants$Mratio_g.lower,
y = 50,
xend = metad_group_all_participants$Mratio_g.upper,
yend = 50
),
colour = "grey",
size = 2.5) +
ylab("Sample count") +
xlab("Mratio") +
theme_minimal_hgrid()
fig_mcmc

save_plot(
here("output/figures/fig_mcmc.pdf"),
fig_mcmc,
base_width = 12,
base_height = 6.5
)

```

The posterior distribution is `r below_rope`% below the low limit of the ROPE,
`r within_rope`% within the ROPE, and `r above_rope`% above the high limit of the ROPE.
Loading

0 comments on commit f8d94e8

Please sign in to comment.