knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Travis build status

varameta

The goal of varameta is to provide a solution to meta-analysing medians.

Existing solutions either convert medians to means, or omit the studies that report medians. varameta provides all existing methods, including a new esitmator for the variance of the sample median, enabling meta-analysis of medians.

This package has some secondary objectives, however, for the creator. As my first foray into reproducible packaged analyses, version control with git, and package development, much that is pedestrian in varameta was dazzlingly fascinating in its novelty.

installation

You can install varameta from github with:

# install.packages("devtools")
devtools::install_github("softloud/varameta")

A minimal demonstration of calculating the variance of the sample median

# packages
library(panda) # for panda
library(tidyverse)
library(simeta) # for sim_stats
library(varameta) 

# for reproducibility
set.seed(39)
panda("show me the code!")

Compute standard error of the sample median

sample_size <- 30

# get a sample
a_sample <- rexp(sample_size)

# get standard error of the sample median
effect_se(
  centre = median(a_sample),
  spread = IQR(a_sample),
  n = length(a_sample),
  centre_type = "median",
  spread_type = "iqr"
)

Vectorised calculations for dataframes

Here we borrow a function from the companion simeta:: package. See below for details.

# generate random meta-analysis dataset
# one row per study

(ma_sample <- sim_stats() %>%
  # filter down to one group per study
  dplyr::filter(group == "control"))


ma_sample %>%
  # append a column with the standard error of the median for each study
  mutate(effect_se = pmap_dbl(
    list(centre = effect,
         spread = effect_spread,
         n = n),
    effect_se,
    centre_type = "median",
    spread_type = "iqr"
  ))

packaged analyses

This was the first time I really (figuratively) cracked open the canonical R packages.

As someone who has built towering pillars of script files, it was quite the revelation to switch to storing my functions reproducibly with documentation.

Unit testing as a debugging tool, was also a highlight discovery.

"If you’re using automated testing, this is also a good time to create an automated test case. If your existing test coverage is low, take the opportunity to add some nearby tests to ensure that existing good behaviour is preserved. This reduces the chances of creating a new bug." (Advanced R)

git

A doctorate is a grand time of firsts. First package, first paper, first conference talk, and first collaboration. Suddenly sharing my code, collaborating on it, and tracking large projects are pressing concerns.

Learning git via the entertaining Happy Git and GitHub for the useR was the solution I went with. A frustrating learning curve at times; e.g.,

{bash eval = FALSE} git config --global core.editor "nano"

is a command I wish I learnt a lot earlier. I'm convinced that vim was designed by GLaDOS.



softloud/varameta documentation built on Feb. 8, 2023, 12:12 a.m.