This file contains 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
## Checks for associations between politics and posting at SSC, using Beta-Bayes! | |
## Data from: http://slatestarcodex.com/Stuff/ssc2018public.xlsx | |
library("tidyverse") | |
SSC = read_excel("ssc2018public.xlsx") # Downloaded from SSC. | |
Politics = as.factor(SSC$PoliticalAffiliation) | |
Comments = as.factor(SSC$Comment) | |
## Not everyone will agree with my classification. |
This file contains 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
## Makes a plot checking for clear associations between politics and postign in SSC. | |
## Data from: http://slatestarcodex.com/Stuff/ssc2018public.xlsx | |
library("tidyverse") | |
SSC = read_excel("ssc2018public.xlsx") # Downloaded from SSC. | |
Politics = as.factor(SSC$PoliticalAffiliation) | |
Comments = as.factor(SSC$Comment) | |
## Not everyone will agree with my classification. |
This file contains 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
N = 1000 | |
K = 1 | |
res = MCMCpack::rdirichlet(N, K*c(0.1, 0.15, 0.7, 0.05)) | |
score = rowSums(res^2) | |
trust = res%*%c(-1,-1,1,0) + rnorm(N, 0, 0.1) | |
covs = data.frame(afro = res[1,], latios = res[2,], whites = res[3,], asians = res[4,], score = score) | |
lm(trust ~ ., data = covs) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
## Needed to calculate moments. | |
library("moments") | |
set.seed(313) | |
## An illustration with both variables skewed. | |
n = 200 | |
x = rbeta(n, 1, 15) | |
y = 3 + x + rnorm(n, 0, 0.01) | |
## Plotting! |
This file contains 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
## This script uses the tmvtnorm package, check it out. | |
if(!("tmvtnorm" %in% rownames(installed.packages()))) { | |
install.packages("tmvtnorm") | |
} | |
library("tmvtnorm") | |
## Seed for reproducibility. | |
set.seed(313) |
NewerOlder