Skip to content
{{ message }}

Instantly share code, notes, and snippets.

# svmiller/an-idiot-approach-to-priors.R

Last active Feb 8, 2021
How to be an idiot with priors in R
 library(tidyverse) library(stevedata) library(brms) # what follows is me being an idiot. Don't be Steve. Don't be an idiot. ?therms # For anyone with a brain: the better you think of Obama, the worse you think of Trump (and vice-versa). M1 <- lm(fttrump1 ~ ftobama1, data=therms) summary(M1) # But I'm choosing to be an idiot, so let's use that and be an idiot with prior distributions in R. # Let's flip the sign of that coefficient/standard error, and then proceed to more idiocy. idiot_prior1 <- c(set_prior("normal(.653, .015)", class="b", coef="ftobama1")) idiot_prior2 <- c(set_prior("normal(6.53, .015)", class="b", coef="ftobama1")) idiot_prior3 <- c(set_prior("normal(65.3, .015)", class="b", coef="ftobama1")) B1 <- brm(fttrump1 ~ ftobama1, data=therms, seed = 8675309, prior = idiot_prior1, family = gaussian()) B2 <- brm(fttrump1 ~ ftobama1, data=therms, seed = 8675309, prior = idiot_prior2, family = gaussian()) B3 <- brm(fttrump1 ~ ftobama1, data=therms, seed = 8675309, prior = idiot_prior3, family = gaussian()) summary(B1) summary(B2) summary(B3) # ^ don't be an idiot with prior distributions in your Bayesian analyses.
to join this conversation on GitHub. Already have an account? Sign in to comment