Plot of table 4

library(readxl)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.0     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
theme_set(theme_classic(base_size = 16))
dat <- read_excel("C:/Users/stefa/Dropbox/~ Quant book club/Missing data RF/Revisions March 2024/Book2.xlsx")
head(dat)
# A tibble: 6 × 6
  path  missing     n  raux method  prop
  <chr> <chr>   <dbl> <dbl> <chr>  <dbl>
1 a1    MCAR      100   0.5 t       0.05
2 a4    MCAR      100   0.5 t       0.04
3 Both  MCAR      100   0.5 t       0.01
4 Other MCAR      100   0.5 t       0.25
5 None  MCAR      100   0.5 t       0.71
6 a1    MCAR      100   0.9 t       0.04

Order factor variables

dat <- dat %>%
    mutate(path = fct_relevel(path, c("a1", "a4", "Both", "Other", "None"))) %>%
    mutate(missing = fct_relevel(missing, c("MCAR", "MARL", "MARC", "MARI"))) %>%
    mutate(method = fct_relevel(method, c("t", "log", "hol", "las", "rf")))
head(dat)
# A tibble: 6 × 6
  path  missing     n  raux method  prop
  <fct> <fct>   <dbl> <dbl> <fct>  <dbl>
1 a1    MCAR      100   0.5 t       0.05
2 a4    MCAR      100   0.5 t       0.04
3 Both  MCAR      100   0.5 t       0.01
4 Other MCAR      100   0.5 t       0.25
5 None  MCAR      100   0.5 t       0.71
6 a1    MCAR      100   0.9 t       0.04

All data

Y is prop, X is path

ggplot(data = dat, aes(x = path, y = prop)) +
    geom_col() +
    facet_grid(vars(n, raux), vars(missing, method))

Y is prop, X is method

ggplot(data = dat, aes(x = method, y = prop)) +
    geom_col() +
    facet_grid(vars(n, raux), vars(missing, path))

Too much data: Use only n = 1000 and raux = 0.5

dat1 <- dat %>%
    filter(n == 1000) %>%
    filter(raux == 0.5)
ggplot(data = dat1, aes(x = path, y = prop)) +
    geom_col() +
    facet_grid(vars(method), vars(missing)) +
    theme(axis.text.x=element_text(angle=45, hjust=1)) 

ggplot(data = dat1, aes(x = method, y = prop)) +
    geom_col() +
    facet_grid(vars(path), vars(missing))

Too much data: Use only n = 1000 and raux = 0.9

dat2 <- dat %>%
    filter(n == 1000) %>%
    filter(raux == 0.9)
ggplot(data = dat2, aes(x = path, y = prop)) +
    geom_col() +
    facet_grid(vars(method), vars(missing)) +
    theme(axis.text.x=element_text(angle=45, hjust=1))

ggplot(data = dat2, aes(x = method, y = prop)) +
    geom_col() +
    facet_grid(vars(path), vars(missing))

Too much data: Use only n = 100 and raux = 0.5

dat3 <- dat %>%
    filter(n == 100) %>%
    filter(raux == 0.5)
ggplot(data = dat3, aes(x = path, y = prop)) +
    geom_col() +
    facet_grid(vars(method), vars(missing)) +
    theme(axis.text.x=element_text(angle=45, hjust=1))

ggplot(data = dat3, aes(x = method, y = prop)) +
    geom_col() +
    facet_grid(vars(path), vars(missing))

Too much data: Use only n = 100 and raux = 0.9

dat4 <- dat %>%
    filter(n == 100) %>%
    filter(raux == 0.9)
ggplot(data = dat4, aes(x = path, y = prop)) +
    geom_col() +
    facet_grid(vars(method), vars(missing)) +
    theme(axis.text.x=element_text(angle=45, hjust=1))

ggplot(data = dat4, aes(x = method, y = prop)) +
    geom_col() +
    facet_grid(vars(path), vars(missing))