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

checkBetas.R (1087B)


      1 # Just a hack script to check that I got the sum-to-zero stuff right.
      2 
      3 betaLevels <- c(5, 3, 2)
      4 
      5 # Hey, how do you initialize an empty n-dimentional matrix in R?
      6 mFromBeta <- rep(NA, prod(betaLevels))
      7 dim(mFromBeta) <- betaLevels
      8 mFromMCMC <- rep(NA, prod(betaLevels))
      9 dim(mFromMCMC) <- betaLevels
     10 
     11 for (j1 in 1:betaLevels[1]) {
     12   for (j2 in 1:betaLevels[2]) {
     13     for (j3 in 1:betaLevels[3]) {
     14       # Oh God.
     15       mFromBeta[j1,j2,j3] <- mean(mcmcMat[,"b0"] + 
     16                                     mcmcMat[,paste0("b1[",j1,"]")] + 
     17                                     mcmcMat[,paste0("b2[",j2,"]")] + 
     18                                     mcmcMat[,paste0("b3[",j3,"]")] + 
     19                                     mcmcMat[,paste0("b1b2[",j1,",",j2,"]")] + 
     20                                     mcmcMat[,paste0("b1b3[",j1,",",j3,"]")] + 
     21                                     mcmcMat[,paste0("b2b3[",j2,",",j3,"]")] + 
     22                                     mcmcMat[,paste0("b1b2b3[",j1,",",j2,",",j3,"]")])
     23       mFromMCMC[j1,j2,j3] <- mean(mcmcMat[,paste0("m[",j1,",",j2,",",j3,"]")])
     24     }
     25   }
     26 }