Skip to content

Instantly share code, notes, and snippets.

View benwhalley's full-sized avatar

Ben Whalley benwhalley

  • Plymouth University
View GitHub Profile
@benwhalley
benwhalley / kidiq.csv
Last active September 4, 2018 09:11
Kids IQ data from the Gelman and Hill ARM book
kid_score mom_hs mom_iq mom_work mom_age
65 Completed 121.118 4 27
98 Completed 89.362 4 25
85 Completed 115.443 4 27
83 Completed 99.45 3 25
115 Completed 92.746 4 27
98 Did not complete 107.902 1 18
69 Completed 138.893 4 20
106 Completed 125.145 3 23
102 Completed 81.62 1 24
month temperature day.of.week icecreams.sold
5 18.46 Su 60
6 20.42 Th 102
1 13.02 Sa 62
3 17.98 We 46
6 14.31 Su 110
4 16.87 Th 24
8 23.77 Th 52
2 11.02 Tu 26
12 14.36 We 46
@benwhalley
benwhalley / a
Created September 4, 2018 08:43
c
@benwhalley
benwhalley / Ben.plist
Last active September 19, 2018 07:54
Mailmate key bindings
{
// Mailmate keybindings
"\U007F" = "archive:"; // ⌫
"@\U007F" = "deleteMessage:"; // ⌘+⌫
" " = "scrollPageDownOrNextUnreadMessage:";
"@S" = "saveAttachments:";
// Based on: https://mail.google.com/support/bin/answer.py?answer=6594
library(brms)
library(tidyverse)
m1 <- rstanarm::stan_glm(mpg~wt, data=mtcars)
prior_summary(m1)
# see what priors brms will let you set
get_prior(mpg~wt, data=mtcars)
# then then mimic beta priors from rstanarm (inc rstanarm autoscaling)
m2 <- brm(mpg~wt, data=mtcars, sample_prior="only",
Prior <- c(set_prior("normal(0, 30)", class = "b"))
options(mc.cores=parallel::detectCores ()-1)
f.interaction <- bf(Pressure ~ Awareness *
Agency *
Resp.Alt *
VisualPrime *
---
title: Quantifying uncertainty
output: html_document
---
```{r}
library(tidyverse)
```
@benwhalley
benwhalley / priors.Rmd
Created October 4, 2018 15:10
example of droopy densities
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
wt .row .chain .iteration estimate dist
1 1 NA 1 35.63558606434021 posterior
1 1 NA 2 28.530141107955775 posterior
1 1 NA 3 29.350245281355008 posterior
1 1 NA 4 29.451646459250988 posterior
1 1 NA 5 29.95125999190543 posterior
1 1 NA 6 29.819994020090522 posterior
1 1 NA 7 36.52057328196404 posterior
1 1 NA 8 35.9813523220044 posterior
1 1 NA 9 35.617712360402834 posterior
@benwhalley
benwhalley / table_helpers.R
Last active November 13, 2018 13:20
table formatting helper functions
sprintcol <- function(x, sig.digits = 3) {
rounded <- paste(signif(x, sig.digits))
max.decimal <-
str_extract(rounded, "\\.(\\d+)") %>%
str_length() %>%
max(c(0, .), na.rm = T) - 1
max.decimal <- max(max.decimal, min(abs(max.decimal), 0))
sprintf(fmt = glue::glue("%.{max.decimal}f"), x)
}