antivax-attitudes

Reanalyses of data from Horne, Powell, Hummel & Holyoak (2015)
git clone https://git.eamoncaddigan.net/antivax-attitudes.git
Log | Files | Refs | README | LICENSE

commit 0fa77a29683e1d68163bc8d9cee6410dcd026611
parent 30c5f346199548d8aed681b853fcb2e72cd91484
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Tue, 15 Sep 2015 21:58:31 -0400

Preintervention samples.

Diffstat:
Mantivax-bootstrap.Rmd | 29+++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/antivax-bootstrap.Rmd b/antivax-bootstrap.Rmd @@ -21,10 +21,6 @@ library(tidyr) library(dplyr) library(ggplot2) library(gridExtra) -library(rjags) -library(runjags) -source("DBDA2E-utilities.R") -source("ggPostPlot.R") # Clean and process the data -------------------------------------------------- @@ -80,4 +76,26 @@ Some of my friends offered insightful comments, and one [pointed out](https://tw ![Posteror of final score differences](https://pbs.twimg.com/media/COE2e8bUkAEeu8b.png:large) -Still, interpreting differences in parameter values isn't always straightforward, so I thought it'd be fun to try a different approach. Instead of modeling the (process that generated the) data, we can use bootstrapping to estimate population parameters using the sample. [Bootstrapping is cool and simple](https://en.wikipedia.org/wiki/Bootstrapping_(statistics)), and it's one of those great techniques that people would've been using all along had computers been around in the early days of statistics. -\ No newline at end of file +Still, interpreting differences in parameter values isn't always straightforward, so I thought it'd be fun to try a different approach. Instead of modeling the (process that generated the) data, we can use bootstrapping to estimate population parameters using the sample. [Bootstrapping is cool and simple](https://en.wikipedia.org/wiki/Bootstrapping_(statistics)), and it's one of those great techniques that people would've been using all along had computers been around in the early days of statistics. + +```{r } +# Bootstrap to find the probability that each response will be given to pre-test +# questions. +numBootstraps <- 1e5 +numObservations <- nrow(questionnaireData) +numResponseValues <- length(unique(questionnaireData$response)) + +preinterventionData <- matrix(data = 0, + nrow = numBootstraps, + ncol = numResponseValues) +for (ii in seq_len(numBootstraps)) { + bootSamples <- sample(questionnaireData$response, + numObservations, + replace = TRUE) + bootTable <- table(bootSamples) + preinterventionData[ii, as.integer(names(bootTable))] <- bootTable +} +preinterventionData <- preinterventionData / numObservations + +``` +