Skip to content

Instantly share code, notes, and snippets.

@mathesong
mathesong / Power_Question.md
Last active November 9, 2023 19:27
Power Question: multiple noisy measurements vs single noiseless outcome

Aim

I want to simulate to demonstrate how it's possible that the hierarchical model can even have better power than getting exactly the right values.

Note: The original question and results are no longer applicable due to a few fatal flaws with my code. Below follows the correct code. But the oracle is optimal now...

Libraries

@mathesong
mathesong / mgcv_predict1000
Created February 19, 2019 11:24
I cannot predict more than 1000 points using the mgcv package at a time, otherwise it starts repeating the values
library(mgcv)
library(tidyverse)
# Data
BPR <-
tibble::tribble(
~time, ~bpr,
50, 0.892042350231095,
170, 0.888132434012036,
@mathesong
mathesong / reliability_gif.R
Created November 15, 2018 17:15
Code to make a gif demonstrating varying degrees of reliability, and the amount of measurement error relative to the true variation in the data. This comes from trying to explain concepts in my preprint here: https://www.biorxiv.org/content/early/2018/06/05/274894
library(tidyverse)
library(magick)
# devtools::install_github("thomasp85/patchwork")
library(patchwork)
colours = c("#85d4e3",
"#e39f85")
set.seed(40)
@mathesong
mathesong / reminderbot.R
Last active November 9, 2023 19:16
Making a Reminder Bot for Automating Meeting Organisation with R and Google Sheets
# Please note that this script is not fully tested. This is a genericised
# version of two working versions, where I've added and removed bits and
# pieces along the way without testing them. Please let me know if there
# are errors or things missing, because this could easily have happened.
library(tidyverse)
library(googlesheets)
library(lubridate)
library(gmailr)