Last active
February 8, 2021 22:09
-
-
Save svmiller/a592dcfcf63826fb73e33d5555940285 to your computer and use it in GitHub Desktop.
How to be an idiot with priors in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment