Skip to content

Instantly share code, notes, and snippets.

View benwhalley's full-sized avatar

Ben Whalley benwhalley

  • Plymouth University
View GitHub Profile
patient dose improvement
1 0 2.197621767238937
2 0 3.8491125525836
3 0 12.79354157074562
4 0 5.35254195712288
5 0 5.646438675804731
6 0 13.575324934416406
7 0 7.304581029946012
8 0 -1.3253061730326703
9 0 1.5657357405323697
person sauce pudding yumminess
1 cream choc 17.197621767238935
2 cream choc 18.849112552583602
3 cream choc 27.79354157074562
4 cream choc 20.35254195712288
5 cream choc 20.64643867580473
6 cream choc 28.575324934416408
7 cream choc 22.30458102994601
8 cream choc 13.67469382696733
9 cream choc 16.565735740532368
library(rstanarm)
library(tidybayes)
m1 <- stan_lmer(t2_accuracy ~ lag*condition + (1|p), data = rsvp_accuracy)
nd <- expand.grid(condition=unique(rsvp_accuracy$condition), lag=factor(c(1,3))) %>% as.tibble() %>% mutate(p=Inf)
m1.preds <- add_fitted_samples(nd, m1)
m1.preds.wide <- m1.preds %>%
data.table::dcast(.iteration+condition~lag)
<?xml version="1.0" ?>
<auth>
<publications>
<publication>
<authors>bjwhalley,thollins</authors>
<elements_id>1</elements_id>
<bibtex>{Stuff here}</bibtex>
<timestamp>2050-01-31T20:00-4:00</timestamp>
</publication>
<publication>
@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)
}
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 / 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)
```
---
title: Quantifying uncertainty
output: html_document
---
```{r}
library(tidyverse)
```
Prior <- c(set_prior("normal(0, 30)", class = "b"))
options(mc.cores=parallel::detectCores ()-1)
f.interaction <- bf(Pressure ~ Awareness *
Agency *
Resp.Alt *
VisualPrime *
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",