---
title: "Empirical Analysis of the Text Structure of Original Research Articles in Medical Journals"
author: "Nicole Heßler, Miriam Rottmann & Andreas Ziegler"
output:
  html_document: default
  word_document: default
---

<!--
This is the R Markdown document to perform the described analyses of the main document.
It requires the provided dataset (Data.xlsx). Some R libraries need to be installed.
-->

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = FALSE)

library(knitr)
library(readxl)
library(metafor)
library(ggplot2)
library(dplyr)
library(lme4)
library(afex)
library(purrr)
library(broom)

# set project directory
projectWD <- "XXX"
setwd(projectWD)

```

```{r functions}

# defined functions
expit <- function(x) { exp(x)/(1 + exp(x)) }
asinTransform <- function(p) { asin(sqrt(p)) }
invasinTransform <- function(x) { (sin(x))^2 }

```

```{r read data}

data <- read_excel("S1_File.xlsx")

# add total number of paragraphs 
data$TotalPar <- data$IntroPar + data$MethPar + data$ResPar + data$DiscPar
# add time variable for linear mixed models: 2005 coded as 0, 2010 coded as 5, 2015 coded as 10
data$timeVariable <- ifelse(data$Year == 2005, 0, ifelse(data$Year == 2010, 5, ifelse(data$Year == 2015, 10, data$Year)))
# recode Supplement: 1: yes, 0: no
data$SupplementsBin <- ifelse(data$Supplements == "yes", 1, 0)

```

# 0. Abbreviations

95CI = 95% confidence interval  
abs = absolute frequency  
BMJ = The BMJ  
Disc = discussion  
FE = fixed effect  
Figs = figures  
IMRAD = introduction, methods, results and discussion  
Intro = introduction   
JAMA = Journal of the American Medical Association   
Meth = methods  
NEJM = New England Journal of Medicine  
PLOS = PLOS Medicine  
 RE = random effect  
Ref = references  
rel = relative frequency  
Res = results  
sd = standard deviation  
SE = standard error  
Supp = supplementary material  
Tabs = tables  
TotalPar = total paragraphs 


# 1. Descriptive statistics

```{r descriptive analyses}

# continuous outcomes
descStatCont1 <- data %>% 
  group_by(Journal, Year) %>%
  summarise(meanIntro = round(mean(IntroPar), 2), sdIntro = round(sd(IntroPar), 2),
            meanMeth = round(mean(MethPar), 2), sdMeth = round(sd(MethPar), 2),
            meanRes = round(mean(ResPar), 2), sdRes = round(sd(ResPar), 2),
            meanDisc = round(mean(DiscPar), 2), sdDisc = round(sd(DiscPar), 2),
            meanTotalPar = round(mean(TotalPar), 2), sdTotalPar = round(sd(TotalPar), 2))

descStatCont2 <- data %>%
  group_by(Journal, Year) %>%
  summarise(meanTabs = round(mean(TablesNumb), 2), sdTabs = round(sd(TablesNumb), 2),
            meanFigs = round(mean(FiguresNumb), 2), sdFigs = round(sd(FiguresNumb), 2),
            meanRef = round(mean(RefNumb), 2), sdRef = round(sd(RefNumb), 2))

# categorical outcomes
descStatCat <- data %>%
  group_by(Journal, Year) %>%
  summarise(absSuppYes = sum(SupplementsBin), relSuppYes = round(absSuppYes/length(SupplementsBin), 2), 
            absIMRADYes = sum(IMRAD=="yes"), relIMRADYes = round(absIMRADYes/length(IMRAD), 2))

```

```{r echo = FALSE, results = "as.is"}

kable(descStatCont1, caption = "Descriptive statistics - paragraphs.")
kable(descStatCont2, caption = "Descriptive statistics - tables, figures and references.")
kable(descStatCat, caption = "Descriptive statistics - supplementary material + IMRAD structure.")

```

# 2. Random effect meta-analyses per year

## 2. 1 Paragraphs

### 2.1.1 Section: Introduction

```{r meta-anal per year intro}

# model
DSL_model_Intro <- descStatCont1 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanIntro, vi = sdIntro^2, method = "DL", data = .)) 
DSL_model_Intro

#extract and combine results
DSL_model_Intro_summary <- DSL_model_Intro %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Intro_summary) <- c("Intro 2005", "Intro 2010", "Intro 2015")

# forest plots
forest(DSL_model_Intro$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs",  main = "Introduction 2005", cex = 1)
forest(DSL_model_Intro$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Introduction 2010", cex = 1)
forest(DSL_model_Intro$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Introduction 2015", cex = 1)

```

### 2.1.2 Section: Methods

```{r meta-anal per year meth}

# model
DSL_model_Meth <- descStatCont1 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanMeth, vi = sdMeth^2, method = "DL", data = .))
DSL_model_Meth

# extract and combine results
DSL_model_Meth_summary <- DSL_model_Meth %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Meth_summary) <- c("Meth 2005", "Meth 2010", "Meth 2015")

# forest plots
forest(DSL_model_Meth$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Methods 2005", cex = 1)
forest(DSL_model_Meth$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Methods 2010", cex = 1)
forest(DSL_model_Meth$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Methods 2015", cex = 1)

```

### 2.1.3 Section: Results

```{r meta-anal per year res}

# model
DSL_model_Res <- descStatCont1 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanRes, vi = sdRes^2, method = "DL", data = .))
DSL_model_Res

# extract and combine results
DSL_model_Res_summary <- DSL_model_Res %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Res_summary) <- c("Res 2005", "Res 2010", "Res 2015")

#forest plots
forest(DSL_model_Res$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Results 2005", cex = 1)
forest(DSL_model_Res$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Results 2010", cex = 1)
forest(DSL_model_Res$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Results 2015", cex = 1) 

```

### 2.1.4 Section: Discussion

```{r meta-anal per year disc}

# model
DSL_model_Disc <- descStatCont1 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanDisc, vi = sdDisc^2, method = "DL", data = .))
DSL_model_Disc

# extract and combine results
DSL_model_Disc_summary <- DSL_model_Disc %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Disc_summary) <- c("Disc 2005", "Disc 2010", "Disc 2015")

#forest plots
forest(DSL_model_Disc$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Discussion 2005", cex = 1)
forest(DSL_model_Disc$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Discussion 2010", cex = 1)
forest(DSL_model_Disc$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Discussion 2015", cex = 1)

```

### 2.1.5 Total paragraphs

```{r meta-anal per year total par}

# model
DSL_model_TotalPar <- descStatCont1 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanTotalPar, vi = sdTotalPar^2, method = "DL", data = .)) 
DSL_model_TotalPar

# extract and combine results
DSL_model_TotalPar_summary <- DSL_model_TotalPar %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_TotalPar_summary) <- c("TotalPar 2005", "TotalPar 2010", "TotalPar 2015")

# forest plots
forest(DSL_model_TotalPar$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Total Paragraphs 2005", cex = 1)
forest(DSL_model_TotalPar$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Total Paragraphs  2010", cex = 1)
forest(DSL_model_TotalPar$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of paragraphs", main = "Total Paragraphs 2015", cex = 1)

```

### 2.1.6 All years combined

```{r meta-anal per year all}

# models
DSL_model_all_Intro <- rma(yi = descStatCont1$meanIntro, vi = descStatCont1$sdIntro^2, method = "DL")
DSL_model_all_Intro
DSL_model_all_Meth <- rma(yi = descStatCont1$meanMeth, vi = descStatCont1$sdMeth^2, method = "DL")
DSL_model_all_Meth
DSL_model_all_Res <- rma(yi = descStatCont1$meanRes, vi = descStatCont1$sdRes^2, method = "DL")
DSL_model_all_Res
DSL_model_all_Disc <- rma(yi = descStatCont1$meanDisc, vi = descStatCont1$sdDisc^2, method = "DL")
DSL_model_all_Disc
DSL_model_all_Total <- rma(yi = descStatCont1$meanTotalPar, vi = descStatCont1$sdTotalPar^2, method = "DL")
DSL_model_all_Total

# combine results
metaAll_summary <- data.frame(
  "Estimate" = round(c(DSL_model_all_Intro$beta, DSL_model_all_Meth$beta, DSL_model_all_Res$beta, DSL_model_all_Disc$beta ,DSL_model_all_Total$beta), 2),
  "SE" = round(c(DSL_model_all_Intro$se,DSL_model_all_Meth$se, DSL_model_all_Res$se, DSL_model_all_Disc$se,DSL_model_all_Total$se), 2),
  "lower95CI" = round(c(DSL_model_all_Intro$ci.lb,DSL_model_all_Meth$ci.lb, DSL_model_all_Res$ci.lb, DSL_model_all_Disc$ci.lb,DSL_model_all_Total$ci.lb), 2), 
  "upper95CI" = round(c(DSL_model_all_Intro$ci.ub,DSL_model_all_Meth$ci.ub, DSL_model_all_Res$ci.ub, DSL_model_all_Disc$ci.ub,DSL_model_all_Total$ci.ub), 2))
rownames(metaAll_summary) <- c("All years: Intro", "All years: Meth", "All years:  Res", "All years: Disc", "All years: Total")

# forest plots
forest(DSL_model_all_Intro, slab = paste(descStatCont1$Journal, descStatCont1$Year, sep=" "), xlab = "Number of paragraphs", main = "All years: Introduction", cex = 1)
forest(DSL_model_all_Meth, slab = paste(descStatCont1$Journal, descStatCont1$Year, sep=" "), xlab = "Number of paragraphs", main = "All years:  Methods", cex = 1)
forest(DSL_model_all_Res, slab = paste(descStatCont1$Journal, descStatCont1$Year, sep=" "), xlab = "Number of paragraphs", main = "All years: Results", cex = 1)
forest(DSL_model_all_Disc, slab = paste(descStatCont1$Journal, descStatCont1$Year, sep=" "), xlab = "Number of paragraphs", main = "All years: Discussion", cex = 1)
forest(DSL_model_all_Total, slab = paste(descStatCont1$Journal, descStatCont1$Year, sep=" "), xlab = "Number of paragraphs", main = "All years: Total paragraphs", cex = 1)

```

### 2.1.8 Overview of results

```{r meta-anal per year output}

# combine all meta-analyses results
metaResultsYear <- rbind(DSL_model_Intro_summary, DSL_model_Meth_summary, DSL_model_Res_summary, DSL_model_Disc_summary, DSL_model_TotalPar_summary, metaAll_summary)

```

```{r echo = FALSE, results = "as.is"}

kable(metaResultsYear, caption = "Random effect meta-analyses per year - paragraphs.")

```

## 2.2 Supplementary material

```{r meta-anal per year suppl}

# PR = raw proportion, PLN = log transfomred proportion, PLO = log odds, PAS = arcsine square root transformed proportion

# PR model
DSL_model_Suppl_PR <- descStatCat %>%
  split(.$Year) %>%
  map(~ escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PR")) %>%
  map(~ rma(yi, vi, data = ., method = "DL"))

# extract and combine results
DSL_model_Suppl_PR_summary <- DSL_model_Suppl_PR %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Suppl_PR_summary) <- c("Raw proportion 2005", "Raw proportion 2010", "Raw proportion 2015")


# PLN model
DSL_model_Suppl_PLN <- descStatCat %>%
  split(.$Year) %>%
  map(~ escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PLN")) %>%
  map(~ rma(yi, vi, data = ., method = "DL"))

# extract and combine results
DSL_model_Suppl_PLN_summary <- DSL_model_Suppl_PLN %>% 
  map(~ data.frame(Estimate = round(exp(.$beta), 2),
    SE = round(.$se, 2),
    lower95CI = round(exp(.$ci.lb), 2),
    upper95CI = round(exp(.$ci.ub), 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Suppl_PLN_summary) <- c("Log transformed proportion 2005","Log transformed proportion 2010", "Log transformed proportion 2015")


# PLO model
DSL_model_Suppl_PLO <- descStatCat %>%
  split(.$Year) %>%
  map(~ escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PLO")) %>%
  map(~ rma(yi, vi, data = ., method = "DL"))

# extract and combine results
DSL_model_Suppl_PLO_summary <- DSL_model_Suppl_PLO %>% 
  map(~ data.frame(Estimate = round(expit(.$beta), 2),
    SE = round(.$se, 2),
    lower95CI = round(expit(.$ci.lb), 2),
    upper95CI = round(expit(.$ci.ub), 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Suppl_PLO_summary) <- c("Logit transformed proportion 2005", "Logit transformed proportion 2010", "Logit transformed proportion 2015")


# PAS model
DSL_model_Suppl_PAS <- descStatCat %>%
  split(.$Year) %>%
  map(~ escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PAS")) %>%
  map(~ rma(yi, vi, data = ., method = "DL"))

# extract and combine results
DSL_model_Suppl_PAS_summary <- DSL_model_Suppl_PAS %>% 
  map(~ data.frame(Estimate = round(invasinTransform(.$beta), 2),
    SE = round(.$se, 2),
    lower95CI = round(invasinTransform(.$ci.lb), 2),
    upper95CI = round(invasinTransform(.$ci.ub), 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Suppl_PAS_summary) <- c("Arcsine square root transformed proportion 2005", "Arcsine square root transformed proportion 2010", "Arcsine square root transformed proportion 2015")


# all years and all yournals
DSL_model_Suppl_all_PR <-  descStatCat %>%
  escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PR") %>%
  rma(yi, vi, data = ., method = "DL")

DSL_model_Suppl_all_PLN <-  descStatCat %>%
  escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PLN") %>%
  rma(yi, vi, data = ., method = "DL")

DSL_model_Suppl_all_PLO <-  descStatCat %>%
  escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PLO") %>%
  rma(yi, vi, data = ., method = "DL")

DSL_model_Suppl_all_PAS <-  descStatCat %>%
  escalc(xi = .$absSuppYes, ni = rep(30, length(.$absSuppYes)), data = ., measure = "PAS") %>%
  rma(yi, vi, data = ., method = "DL")

# combine results
DSL_model_Suppl_summary <- data.frame(
  "Estimate" = round(c(DSL_model_Suppl_all_PR$beta, exp(DSL_model_Suppl_all_PLN$beta), expit(DSL_model_Suppl_all_PLO$beta), invasinTransform(DSL_model_Suppl_all_PAS$beta)), 2),
  "SE" = round(c(DSL_model_Suppl_all_PR$se, DSL_model_Suppl_all_PLN$se, DSL_model_Suppl_all_PLO$se, DSL_model_Suppl_all_PAS$se), 2),
  "lower95CI" = round(c(DSL_model_Suppl_all_PR$ci.lb, exp(DSL_model_Suppl_all_PLN$ci.lb), expit(DSL_model_Suppl_all_PLO$ci.lb), invasinTransform(DSL_model_Suppl_all_PAS$ci.lb)), 2),
  "upper95CI" = round(c(DSL_model_Suppl_all_PR$ci.ub, exp(DSL_model_Suppl_all_PLN$ci.ub), expit(DSL_model_Suppl_all_PLO$ci.ub), invasinTransform(DSL_model_Suppl_all_PAS$ci.ub)), 2))
rownames(DSL_model_Suppl_summary) <- c("All years: Raw proportion", "All years: Log transfomred proportion", "All years: Logit transformed proportion", "All years: Arcsine square root transformed proportion")

metaResultsSupplYear <- rbind(DSL_model_Suppl_PR_summary, DSL_model_Suppl_PLN_summary, DSL_model_Suppl_PLO_summary, DSL_model_Suppl_PAS_summary, DSL_model_Suppl_summary)

```

```{r echo = FALSE, results = "as.is"}

kable(metaResultsSupplYear, caption = "Meta-analyses per year - supplementary material. Standard errors (SE) were not back transformed. Literature recommendation is logit transformed proportion (Lipsey, M. W. and Wilson, D. B. (2001). Practical meta-analysis. Thousand Oaks: Sage) if p < .2 or > .8. Against use of Freeman-Tukey double arcsine transformed proportion: doi 10.1002/jrsm.1348.")

```

## 2.3 Other criteria
### 2.3.1 Tables

```{r meta-anal per year tabs}

# model
DSL_model_Tabs <- descStatCont2 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanTabs, vi = sdTabs^2, method = "DL", data = .)) 
DSL_model_Tabs

# extract and combine results
DSL_model_Tabs_summary <- DSL_model_Tabs %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Tabs_summary) <- c("Tables 2005", "Tables 2010", "Tabels 2015")

# forest plots
forest(DSL_model_Tabs$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of tables", main = "Tables 2005", cex = 1)
forest(DSL_model_Tabs$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of tables", main = "Tables 2010", cex = 1)
forest(DSL_model_Tabs$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of tables", main = "Tables 2015", cex = 1)

```

### 2.3.2 Figures

```{r meta-anal per year figs}

# model
DSL_model_Figs <- descStatCont2 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanFigs, vi = sdFigs^2, method = "DL", data = .)) 
DSL_model_Figs

# extract and combine results
DSL_model_Figs_summary <- DSL_model_Figs %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Figs_summary) <- c("Figures 2005", "Figures 2010", "Figures 2015")

# forest plots
forest(DSL_model_Figs$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of figures", main = "Figures 2005", cex = 1)
forest(DSL_model_Figs$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of figures", main = "Figures 2010", cex = 1)
forest(DSL_model_Figs$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of figures", main = "Figures 2015", cex = 1)

```

### 2.3.3 References

```{r meta-anal per year refs}

# model 
DSL_model_Refs <- descStatCont2 %>%
  split(.$Year) %>%
  map(~ rma(yi = meanRef, vi = sdRef^2, method = "DL", data = .)) 
DSL_model_Refs

# extract and combine results
DSL_model_Refs_summary <- DSL_model_Refs %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Refs_summary) <- c("Referencess 2005", "Referencess 2010", "References 2015")

# forest plots
forest(DSL_model_Refs$'2005', slab = unique(descStatCont1$Journal), xlab = "Number of references", main = "References 2005", cex = 1)
forest(DSL_model_Refs$'2010', slab = unique(descStatCont1$Journal), xlab = "Number of references", main = "References 2010", cex = 1)
forest(DSL_model_Refs$'2015', slab = unique(descStatCont1$Journal), xlab = "Number of references", main = "References 2015", cex = 1)

```

### 2.3.4 All years combined

```{r meta-anal per year all other}

# models
DSL_model_all_Tabs <- rma(yi = descStatCont2$meanTabs, vi = descStatCont2$sdTabs^2, method = "DL")
DSL_model_all_Tabs

DSL_model_all_Figs <- rma(yi = descStatCont2$meanFigs, vi = descStatCont2$sdFigs^2, method = "DL")
DSL_model_all_Figs

DSL_model_all_Refs <- rma(yi = descStatCont2$meanRef, vi = descStatCont2$sdRef^2, method = "DL")
DSL_model_all_Refs

# combine results
metaAll_other_summary <- data.frame(
  "Estimate" = round(c(DSL_model_all_Tabs$beta, DSL_model_all_Figs$beta, DSL_model_all_Refs$beta), 2),
  "SE" = round(c(DSL_model_all_Tabs$se,DSL_model_all_Figs$se, DSL_model_all_Refs$se), 2),
  "lower95CI" = round(c(DSL_model_all_Tabs$ci.lb, DSL_model_all_Figs$ci.lb, DSL_model_all_Refs$ci.lb), 2), 
  "upper95CI" = round(c(DSL_model_all_Tabs$ci.ub, DSL_model_all_Figs$ci.ub, DSL_model_all_Refs$ci.ub), 2))
rownames(metaAll_other_summary) <- c("All years:Tables", "All years: Figures", "All years: References")

# forest plots
forest(DSL_model_all_Tabs, slab = paste(descStatCont2$Journal, descStatCont2$Year, sep=" "), xlab = "Number of tables", main = "All years: Tables", cex = 1)
forest(DSL_model_all_Figs, slab = paste(descStatCont2$Journal, descStatCont2$Year, sep=" "), xlab = "Number of figures", main = "All years:  Figures", cex = 1)
forest(DSL_model_all_Refs, slab = paste(descStatCont2$Journal, descStatCont2$Year, sep=" "), xlab = "Number of references", main = "All years: References", cex = 1)

```

### 2.3.5 Overview of results

```{r meta-anal per year other output}

# combine all meta-analyses results
metaResultsYearOther <- rbind(DSL_model_Tabs_summary, DSL_model_Figs_summary, DSL_model_Refs_summary, metaAll_other_summary)

```

```{r echo = FALSE, results = "as.is"}

kable(metaResultsYearOther, caption = "Random effect meta-analyses per year - tables, figures and references.")

```


# 3. Random effect meta-analyses per journal
## 3.1 Paragraphs
## 3.1.1 Section: Introduction

```{r meta-anal per journal intro}

# model
DSL_model_Intro_Journal <- descStatCont1 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanIntro, vi = sdIntro^2, method = "DL", data = .)) 
DSL_model_Intro_Journal

# extract and combine results
DSL_model_Intro_Journal_summary <- DSL_model_Intro_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Intro_Journal_summary) <- c("BMJ Intro", "JAMA Intro", "LANCET Intro", "NEJM Intro", "PLOS Intro")

# forest plots
forest(DSL_model_Intro_Journal$'BMJ', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "BMJ Introduction", cex = 1)
forest(DSL_model_Intro_Journal$'JAMA', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "JAMA Introduction", cex = 1)
forest(DSL_model_Intro_Journal$'Lancet', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "LANCET Introduction", cex = 1)
forest(DSL_model_Intro_Journal$'NEJM', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "NEJM Introduction", cex = 1)
forest(DSL_model_Intro_Journal$'PLOS', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "PLOS Introduction", cex = 1)

```

## 3.1.2 Section: Methods

```{r meta-anal per journal meth}

# model
DSL_model_Meth_Journal <- descStatCont1 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanMeth, vi = sdMeth^2, method = "DL", data = .)) 
DSL_model_Meth_Journal

#extract and combine results
DSL_model_Meth_Journal_summary <- DSL_model_Meth_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Meth_Journal_summary) <- c("BMJ Meth", "JAMA Meth", "LANCET Meth", "NEJM Meth", "PLOS Meth")

# forest plots
forest(DSL_model_Meth_Journal$'BMJ', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "BMJ Methods", cex = 1)
forest(DSL_model_Meth_Journal$'JAMA', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "JAMA Methods", cex = 1)
forest(DSL_model_Meth_Journal$'Lancet', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "LANCET Methods", cex = 1)
forest(DSL_model_Meth_Journal$'NEJM', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "NEJM Methods", cex = 1)
forest(DSL_model_Meth_Journal$'PLOS', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "PLOS Methods", cex = 1)

```

## 3.1.3 Section: Results

```{r meta-anal per journal res}

# model
DSL_model_Res_Journal <- descStatCont1 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanRes, vi = sdRes^2, method = "DL", data = .)) 
DSL_model_Res_Journal

# extract and combine results
DSL_model_Res_Journal_summary <- DSL_model_Res_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Res_Journal_summary) <- c("BMJ Res", "JAMA Res", "LANCET Res", "NEJM Res", "PLOS Res")

# forest plots
forest(DSL_model_Res_Journal$'BMJ', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "BMJ Results", cex = 1)
forest(DSL_model_Res_Journal$'JAMA', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "JAMA Results", cex = 1)
forest(DSL_model_Res_Journal$'Lancet', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "LANCET Results", cex = 1)
forest(DSL_model_Res_Journal$'NEJM', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "NEJM Results", cex = 1)
forest(DSL_model_Res_Journal$'PLOS', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "PLOS Results", cex = 1)

```

## 3.1.4 Section: Discussion

```{r meta-anal per journal disc}

# model
DSL_model_Disc_Journal <- descStatCont1 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanDisc, vi = sdDisc^2, method = "DL", data = .)) 
DSL_model_Disc_Journal

# extract and combine results
DSL_model_Disc_Journal_summary <- DSL_model_Disc_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Disc_Journal_summary) <- c("BMJ Disc", "JAMA Disc", "LANCET Disc", "NEJM Disc", "PLOS Disc")

# forest plots
forest(DSL_model_Disc_Journal$'BMJ', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "BMJ Discussion", cex = 1)
forest(DSL_model_Disc_Journal$'JAMA', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "JAMA Discussion", cex = 1)
forest(DSL_model_Disc_Journal$'Lancet', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "LANCET Discussion", cex = 1)
forest(DSL_model_Disc_Journal$'NEJM', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "NEJM Discussion", cex = 1)
forest(DSL_model_Disc_Journal$'PLOS', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "PLOS Discussion", cex = 1)

```

## 3.1.5 Total paragraphs

```{r meta-anal per journal total par}

# model
DSL_model_Total_Journal <- descStatCont1 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanTotalPar, vi = sdTotalPar^2, method = "DL", data = .)) 
DSL_model_Total_Journal

# extract and combine results
DSL_model_Total_Journal_summary <- DSL_model_Total_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Total_Journal_summary) <- c("BMJ Total Par", "JAMA Total Par", "LANCET Total Par", "NEJM Total Par", "PLOS Total Par")

# forest plots
forest(DSL_model_Total_Journal$'BMJ', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "BMJ Total Paragraphs", cex = 1)
forest(DSL_model_Total_Journal$'JAMA', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "JAMA Total Paragraphs", cex = 1)
forest(DSL_model_Total_Journal$'Lancet', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "LANCET Total Paragraphs", cex = 1)
forest(DSL_model_Total_Journal$'NEJM', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "NEJM Total Paragraphs", cex = 1)
forest(DSL_model_Total_Journal$'PLOS', slab = unique(descStatCont1$Year), xlab = "Number of paragraphs", main = "PLOS Total Paragraphs", cex = 1)

```

## 3.1.6 Overview of results

```{r meta-anal per journal output}

# combine all meta-analyses results
metaResultsJournal <- rbind(DSL_model_Intro_Journal_summary, DSL_model_Meth_Journal_summary, DSL_model_Res_Journal_summary,  DSL_model_Disc_Journal_summary, DSL_model_Total_Journal_summary)

```

```{r echo = FALSE, results = "as.is"}

kable(metaResultsJournal, caption = "Random effect meta-analyses per journal - paragraphs.")

```


## 3.2 Other criteria
### 3.2.1 Tables

```{r meta-anal per journal tabs}

# model
DSL_model_Tabs_Journal <- descStatCont2 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanTabs, vi = sdTabs^2, method = "DL", data = .)) 
DSL_model_Tabs_Journal

# extract and combine results
DSL_model_Tabs_Journal_summary <- DSL_model_Tabs_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Tabs_Journal_summary) <- c("BMJ Tabs", "JAMA Tabs", "LANCET Tabs", "NEJM Tabs", "PLOS Tabs")

# forest plots
forest(DSL_model_Tabs_Journal$'BMJ', slab = unique(descStatCont2$Year), xlab = "Number of tables", main = "BMJ Tables", cex = 1)
forest(DSL_model_Tabs_Journal$'JAMA', slab = unique(descStatCont2$Year), xlab = "Number of tables", main = "JAMA Tables", cex = 1)
forest(DSL_model_Tabs_Journal$'Lancet', slab = unique(descStatCont2$Year), xlab = "Number of tables", main = "LANCET Tables", cex = 1)
forest(DSL_model_Tabs_Journal$'NEJM', slab = unique(descStatCont2$Year), xlab = "Number of tables", main = "NEJM Tables", cex = 1)
forest(DSL_model_Tabs_Journal$'PLOS', slab = unique(descStatCont2$Year), xlab = "Number of tables", main = "PLOS Tables", cex = 1)

```

### 3.2.2 Figures

```{r meta-anal per journal figs}

# model
DSL_model_Figs_Journal <- descStatCont2 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanFigs, vi = sdFigs^2, method = "DL", data = .)) 
DSL_model_Figs_Journal

# extract and combine results
DSL_model_Figs_Journal_summary <- DSL_model_Figs_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Figs_Journal_summary) <- c("BMJ Figs", "JAMA Figs", "LANCET Figs", "NEJM Figs", "PLOS Figs")

# forest plots
forest(DSL_model_Figs_Journal$'BMJ', slab = unique(descStatCont2$Year), xlab = "Number of figures", main = "BMJ Figures", cex = 1)
forest(DSL_model_Figs_Journal$'JAMA', slab = unique(descStatCont2$Year), xlab = "Number of figures", main = "JAMA Figures", cex = 1)
forest(DSL_model_Figs_Journal$'Lancet', slab = unique(descStatCont2$Year), xlab = "Number of figures", main = "LANCET Figures", cex = 1)
forest(DSL_model_Figs_Journal$'NEJM', slab = unique(descStatCont2$Year), xlab = "Number of figures", main = "NEJM Figures", cex = 1)
forest(DSL_model_Figs_Journal$'PLOS', slab = unique(descStatCont2$Year), xlab = "Number of figures", main = "PLOS Figures", cex = 1)

```

### 3.2.3 References

```{r meta-anal per journal refs}

# model
DSL_model_Refs_Journal <- descStatCont2 %>%
  split(.$Journal) %>%
  map(~ rma(yi = meanRef, vi = sdRef^2, method = "DL", data = .)) 
DSL_model_Refs_Journal

# extract and combine results
DSL_model_Refs_Journal_summary <- DSL_model_Refs_Journal %>% 
  map(~ data.frame(Estimate = round(.$beta, 2),
    SE = round(.$se, 2),
    lower95CI = round(.$ci.lb, 2),
    upper95CI = round(.$ci.ub, 2))) %>%
  do.call("rbind", .)
rownames(DSL_model_Refs_Journal_summary) <- c("BMJ Refs", "JAMA Refs", "LANCET Refs", "NEJM Refs", "PLOS Refs")

# forest plots
forest(DSL_model_Refs_Journal$'BMJ', slab = unique(descStatCont2$Year), xlab = "Number of references", main = "BMJ References", cex = 1)
forest(DSL_model_Refs_Journal$'JAMA', slab = unique(descStatCont2$Year), xlab = "Number of references", main = "JAMA References", cex = 1)
forest(DSL_model_Refs_Journal$'Lancet', slab = unique(descStatCont2$Year), xlab = "Number of references", main = "LANCET References", cex = 1)
forest(DSL_model_Refs_Journal$'NEJM', slab = unique(descStatCont2$Year), xlab = "Number of references", main = "NEJM References", cex = 1)
forest(DSL_model_Refs_Journal$'PLOS', slab = unique(descStatCont2$Year), xlab = "Number of references", main = "PLOS References", cex = 1)

```

## 3.2.4 Overview of results

```{r meta-anal per journal other output}

# combine all meta-analyses results
metaResultsOtherJournal <- rbind(DSL_model_Tabs_Journal_summary, DSL_model_Figs_Journal_summary, DSL_model_Refs_Journal_summary)

```

```{r echo = FALSE, results = "as.is"}

kable(metaResultsOtherJournal, caption = "Random effect meta-analyses per journal - tables, figures and references.")

```

# 4. Linear mixed models
## 4.1 Contrast test for PLOS
FE: journal, RE: year, no intercept model

## 4.1.1 Paragraphs

```{r contrast methods PLOS intro}

# linear mixed model without intercept for journal (FE) and year (RE)
lmm_contrast <- data %>%
  select("IntroPar", "MethPar", "ResPar", "DiscPar", "TotalPar") %>% 
  map(function(x) lmer( x ~ data$Journal + (1|data$timeVariable) + 0, data = data)) 

# point estimates
par_est <- lmm_contrast %>%
  map(function(x) fixef(x)) %>% 
  do.call("rbind", .)

# covariance matrix
vcov_est <- lmm_contrast %>%
  map(function(x) vcov(x))

vcov_est_intro <- vcov_est$IntroPar
vcov_est_meth <- vcov_est$MethPar
vcov_est_res <- vcov_est$ResPar
vcov_est_disc <- vcov_est$DiscPar
vcov_est_total <- vcov_est$TotalPar

# vector of contrasts, PLOS is journal number 5 in the row
# alphabetically ordered
contrast_lmm <- c(-0.25, -0.25, -0.25, -0.25, +1)

# mean estimate of the linear contrast
par_est_tmp <- contrast_lmm * t(par_est)
mean_est_contrast <- apply(par_est_tmp, 2, sum)

# variance estimate of the linear contrast
var_est_intro_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_intro)))
var_est_meth_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_meth)))
var_est_res_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_res)))
var_est_disc_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_disc)))
var_est_total_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_total)))

# lower bound of the 95% confidence interval for the linear contrast
ci_est_intro_contrast_lo <- mean_est_contrast[1] - qnorm(0.975) * sqrt(var_est_intro_contrast)
ci_est_meth_contrast_lo <- mean_est_contrast[2] - qnorm(0.975) * sqrt(var_est_meth_contrast)
ci_est_res_contrast_lo <- mean_est_contrast[3] - qnorm(0.975) * sqrt(var_est_res_contrast)
ci_est_disc_contrast_lo <- mean_est_contrast[4] - qnorm(0.975) * sqrt(var_est_disc_contrast)
ci_est_total_contrast_lo <- mean_est_contrast[5] - qnorm(0.975) * sqrt(var_est_total_contrast)

# upper bound of the 95% confidence interval for the linear contrast
ci_est_intro_contrast_up <- mean_est_contrast[1] + qnorm(0.975) * sqrt(var_est_intro_contrast)
ci_est_meth_contrast_up <- mean_est_contrast[2] + qnorm(0.975) * sqrt(var_est_meth_contrast)
ci_est_res_contrast_up <- mean_est_contrast[3] + qnorm(0.975) * sqrt(var_est_res_contrast)
ci_est_disc_contrast_up <- mean_est_contrast[4] + qnorm(0.975) * sqrt(var_est_disc_contrast)
ci_est_total_contrast_up <- mean_est_contrast[5] + qnorm(0.975) * sqrt(var_est_total_contrast)

# two-sided p-value from the Wald test for the hypothesis that the linear contrast equals zero
p_wald_intro_contrast <- 2*(1 - pnorm(mean_est_contrast[1] / sqrt(var_est_intro_contrast)))
p_wald_meth_contrast <- 2*(1 - pnorm(mean_est_contrast[2] / sqrt(var_est_meth_contrast)))
p_wald_res_contrast <- 2*(1 - pnorm(mean_est_contrast[3] / sqrt(var_est_res_contrast)))
p_wald_disc_contrast <- 2*(1 - pnorm(mean_est_contrast[4] / sqrt(var_est_disc_contrast)))
p_wald_total_contrast <- 2*(1 - pnorm(mean_est_contrast[5] / sqrt(var_est_total_contrast)))

``` 

On average, the number of paragraphs in the introduction in PLOS Medicine is `r round(mean_est_contrast[1], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_intro_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_intro_contrast_lo, digits = 2)`--`r round(ci_est_intro_contrast_up, digits = 2)`.

On average, the number of paragraphs in the methods in PLOS Medicine is `r round(mean_est_contrast[2], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_meth_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_meth_contrast_lo, digits = 2)`--`r round(ci_est_meth_contrast_up, digits = 2)`.

On average, the number of paragraphs in the results in PLOS Medicine is `r round(mean_est_contrast[3], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_res_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_res_contrast_lo, digits = 2)`--`r round(ci_est_res_contrast_up, digits = 2)`.

On average, the number of paragraphs in the discussion in PLOS Medicine is `r round(mean_est_contrast[4], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_disc_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_disc_contrast_lo, digits = 2)`--`r round(ci_est_disc_contrast_up, digits = 2)`.

On average, the total number of paragraphs in PLOS Medicine is `r round(mean_est_contrast[5], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_total_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_total_contrast_lo, digits = 2)`--`r round(ci_est_total_contrast_up, digits = 2)`.


## 4.1.2 Tables, figures and references

```{r contrast methods PLOS tables}

# linear mixed model without intercept for journal (FE) and year (RE)
lmm_contrast_other <- data %>%
  select("TablesNumb", "FiguresNumb", "RefNumb") %>% 
  map(function(x) lmer( x ~ data$Journal + (1|data$timeVariable) + 0, data = data)) 

# point estimates
par_est_other <- lmm_contrast_other %>%
  map(function(x) fixef(x)) %>% 
  do.call("rbind", .)

# covariance matrix
vcov_est_other <- lmm_contrast_other %>%
  map(function(x) vcov(x))

vcov_est_tabs <- vcov_est_other$TablesNumb
vcov_est_figs <- vcov_est_other$FiguresNumb
vcov_est_ref <- vcov_est_other$RefNumb

# vector of contrasts, PLOS is journal number 5 in the row
# alphabetically ordered
contrast_lmm <- c(-0.25, -0.25, -0.25, -0.25, +1)

# mean estimate of the linear contrast
par_est_tmp_other <- contrast_lmm * t(par_est_other)
mean_est_contrast_other <- apply(par_est_tmp_other, 2, sum)

# variance estimate of the linear contrast
var_est_tabs_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_tabs)))
var_est_figs_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_figs)))
var_est_ref_contrast <- sum(as.vector(contrast_lmm) * t(as.vector(contrast_lmm) * t(vcov_est_ref)))

# lower bound of the 95% confidence interval for the linear contrast
ci_est_tabs_contrast_lo <- mean_est_contrast_other[1] - qnorm(0.975) * sqrt(var_est_tabs_contrast)
ci_est_figs_contrast_lo <- mean_est_contrast_other[2] - qnorm(0.975) * sqrt(var_est_figs_contrast)
ci_est_ref_contrast_lo <- mean_est_contrast_other[3] - qnorm(0.975) * sqrt(var_est_ref_contrast)

# upper bound of the 95% confidence interval for the linear contrast
ci_est_tabs_contrast_up <- mean_est_contrast_other[1] + qnorm(0.975) * sqrt(var_est_tabs_contrast)
ci_est_figs_contrast_up <- mean_est_contrast_other[2] + qnorm(0.975) * sqrt(var_est_figs_contrast)
ci_est_ref_contrast_up <- mean_est_contrast_other[3] + qnorm(0.975) * sqrt(var_est_ref_contrast)

# two-sided p-value from the Wald test for the hypothesis that the linear contrast equals zero
p_wald_tabs_contrast <- 2*(1 - pnorm(mean_est_contrast_other[1] / sqrt(var_est_tabs_contrast)))
p_wald_figs_contrast <- 2*(1 - pnorm(mean_est_contrast_other[2] / sqrt(var_est_figs_contrast)))
p_wald_ref_contrast <- 2*(1 - pnorm(mean_est_contrast_other[3] / sqrt(var_est_ref_contrast)))

``` 

On average, the total number of tables in PLOS Medicine is `r round(mean_est_contrast_other[1], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_tabs_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_tabs_contrast_lo, digits = 2)`--`r round(ci_est_tabs_contrast_up, digits = 2)`.

On average, the total number of figures in PLOS Medicine is `r round(mean_est_contrast_other[2], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_figs_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_figs_contrast_lo, digits = 2)`--`r round(ci_est_figs_contrast_up, digits = 2)`.

On average, the total number of references in PLOS Medicine is `r round(mean_est_contrast_other[3], digits = 2)` larger than for the other journals (p = `r format(signif(p_wald_ref_contrast, digits = 1), scientific = F)`). The 95\% confidence interval for this difference is `r round(ci_est_ref_contrast_lo, digits = 2)`--`r round(ci_est_ref_contrast_up, digits = 2)`.

## 4.2 Effect of time
FE: time, RE: journal

# 4.2.1 Paragraphs

```{r linear mixed model}

# fixed effect: time, random effect: journal
lmm_Intro <- lmer(IntroPar ~ timeVariable + (1|Journal), data = data)
lmm_Intro_CI <- confint(lmm_Intro, method = "Wald", level = 0.95)

lmm_Meth <- lmer(MethPar ~ timeVariable + (1|Journal), data = data)
lmm_Meth_CI <- confint(lmm_Meth, method = "Wald", level = 0.95)

lmm_Res <- lmer(ResPar ~ timeVariable + (1|Journal), data = data)
lmm_Res_CI <- confint(lmm_Res, method = "Wald", level = 0.95)

lmm_Disc <- lmer(DiscPar ~ timeVariable + (1|Journal), data = data)
lmm_Disc_CI <- confint(lmm_Disc, method = "Wald", level = 0.95)

lmm_Total <- lmer(TotalPar ~ timeVariable + (1|Journal), data = data)
lmm_Total_CI <- confint(lmm_Total, method = "Wald", level = 0.95)

# combine results
lmm <- data.frame("Estimate" = c(fixef(lmm_Intro)[2], fixef(lmm_Meth)[2], fixef(lmm_Res)[2], fixef(lmm_Disc)[2], fixef(lmm_Total)[2]),
  "lowerWald95CI" = c(lmm_Intro_CI[4,1], lmm_Meth_CI[4,1], lmm_Res_CI[4,1], lmm_Disc_CI[4,1], lmm_Total_CI[4,1]),
  "upperWald95CI" = c(lmm_Intro_CI[4,2], lmm_Meth_CI[4,2], lmm_Res_CI[4,2], lmm_Disc_CI[4,2], lmm_Total_CI[4,2]),
  "p" = c(summary(lmm_Intro)$coefficients[2,5], summary(lmm_Meth)$coefficients[2,5],summary(lmm_Res)$coefficients[2,5], summary(lmm_Disc)$coefficients[2,5], summary(lmm_Total)$coefficients[2,5]))
rownames(lmm) <- c("Intro", "Meth", "Res", "Disc", "TotalPar")

```  

```{r echo = FALSE, results = "as.is"}

kable(lmm, caption = "Linear mixed models - paragraphs.")

``` 

On average, the number of paragraphs in the introduction is `r round(lmm[1,1], digits = 2)` larger per year (p = `r round(lmm[1,4], 4)`, 95% CI: `r round(lmm[1,2], 2)`--`r round(lmm[1,3], 2)`).  
On average, the number of paragraphs of the methods is `r round(lmm[2,1], digits = 2)` larger per year (p = `r round(lmm[2,4], 4)`, 95% CI: `r round(lmm[2,2], 2)`--`r round(lmm[2,3], 2)`).   
On average, the number of paragraphs of the results is `r round(lmm[3,1], digits = 2)` larger per year (p = `r round(lmm[3,4], 4)`, 95% CI: `r round(lmm[3,2], 2)`--`r round(lmm[3,3], 2)`).   
On average, the number of paragraphs of the discussion is `r round(lmm[4,1], digits = 2)` larger per year (p = `r round(lmm[4,4], 4)`, 95% CI: `r round(lmm[4,2], 2)`--`r round(lmm[4,3], 2)`).   
On average, the number of paragraphs in total is `r round(lmm[5,1], digits = 2)` larger per year (p = `r round(lmm[5,4], 4)`, 95% CI: `r round(lmm[5,2], 2)`--`r round(lmm[5,3], 2)`).  


## 4.2.2 Supplementary material

```{r linear mixed model suppl}

# fixed effect: time, random effect: journal
lmm_Suppl <- lmer(SupplementsBin ~ timeVariable + (1|Journal), data = data)
lmm_Suppl_CI <- confint(lmm_Suppl, method = "Wald", level = 0.95)

# combine results
lmm2 <- data.frame("Estimate" = fixef(lmm_Suppl)[2],
  "lowerWald95CI" = lmm_Suppl_CI[4,1],
  "upperWald95CI" = lmm_Suppl_CI[4,2],
  "p" = c(summary(lmm_Suppl)$coefficients[2,5]))

```  

On average, supplementary material increases `r round(lmm2[1,1], digits = 2)` per year (p = `r round(lmm2[1,4], 4)`, 95% CI: `r round(lmm2[1,2], 2)`--`r round(lmm2[1,3], 2)`).  
 

## 4.2.3 Tables, figures and references

```{r linear mixed model other}

# fixed effect: time, random effect: journal
lmm_Tabs <- lmer(TablesNumb ~ timeVariable + (1|Journal), data = data)
lmm_Tabs_CI <- confint(lmm_Tabs, method = "Wald", level = 0.95)

lmm_Figs <- lmer(FiguresNumb ~ timeVariable + (1|Journal), data = data)
lmm_Figs_CI <- confint(lmm_Figs, method = "Wald", level = 0.95)

lmm_Ref <- lmer(RefNumb ~ timeVariable + (1|Journal), data = data)
lmm_Ref_CI <- confint(lmm_Ref, method = "Wald", level = 0.95)

# combine results
lmmCont2 <- data.frame("Estimate" = c(fixef(lmm_Tabs)[2], fixef(lmm_Figs)[2], fixef(lmm_Ref)[2]),
  "lowerWald95CI" = c(lmm_Tabs_CI[4,1], lmm_Figs_CI[4,1], lmm_Ref_CI[4,1]),
  "upperWald95CI" = c(lmm_Tabs_CI[4,2], lmm_Figs_CI[4,2], lmm_Ref_CI[4,2]),
  "p" = c(summary(lmm_Tabs)$coefficients[2,5], summary(lmm_Figs)$coefficients[2,5], summary(lmm_Ref)$coefficients[2,5]))
rownames(lmmCont2) <- c("Tables", "Figures", "References")

```

```{r echo = FALSE, results = "as.is"}

kable(lmmCont2, caption = "Linear mixed models - tables, figures and references.")

``` 

On average, the number of tables did not alter per year (`r round(lmmCont2[1,1], digits = 2)`, p = `r round(lmmCont2[1,4], 4)`, 95% CI: `r round(lmmCont2[1,2], 2)`--`r round(lmmCont2[1,3], 2)`).  
On average, the number of figures increased slightly per year (`r round(lmmCont2[2,1], digits = 2)`, p = `r round(lmmCont2[2,4], 4)`, 95% CI: `r round(lmmCont2[2,2], 2)`--`r round(lmmCont2[2,3], 2)`).  
On average, the number of references increased by `r round(lmmCont2[3,1], digits = 2)` per year (p = `r round(lmmCont2[3,4], 4)`, 95% CI: `r round(lmmCont2[3,2], 2)`--`r round(lmmCont2[3,3], 2)`). 

