Advertisement
Guest User

take 2

a guest
Feb 20th, 2014
291
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Former analysis, without Age/Dose/History covariates:
  2. ## http://slatestarcodex.com/2014/02/16/nootropics-survey-results-and-analysis/#comment-40637
  3. ## http://pastebin.com/faANB3nU
  4.  
  5. library(reshape)
  6. library(lme4)
  7. nootropics <- read.csv("http://dl.dropboxusercontent.com/u/182368464/2014-ssc-nootropicssurvey.csv")
  8. nootropics$Timestamp <- NULL; nootropics$Directions <- NULL # unnecessary
  9. nootropics$CholineHistory <- NA # omitted from original but absence breaks symmetry of the triplet of fields for each nootropic
  10.  
  11. # it's simpler to grep over the column names than list each and every of the 31 columns by hand
  12. # and we need to sort because having to add 'CholineHistory' screws up the otherwise-sorted-hardwired-columns
  13. experiences <- sort(Filter(function (x) {grepl("Experience", x)}, names(nootropics)))
  14. doses <- sort(Filter(function (x) {grepl("Dose", x)}, names(nootropics)))
  15. histories <- sort(Filter(function (x) {grepl("History", x)}, names(nootropics)))
  16. long <- reshape(nootropics, idvar = "Subject", timevar="Nootropic", v.names=c("Response", "Dose", "History"), times=experiences, varying=list(experiences, doses, histories), direction = "long")
  17.  
  18. lmr1 <- lmer(Response ~       (1|Subject) + (1               |Nootropic), data=long)
  19. lmr2 <- lmer(Response ~       (1|Subject) + (    Dose        |Nootropic), data=long)
  20. lmr3 <- lmer(Response ~       (1|Subject) + (         History|Nootropic), data=long)
  21. lmr4 <- lmer(Response ~       (1|Subject) + (    Dose+History|Nootropic), data=long)
  22. lmr5 <- lmer(Response ~ Age + (1|Subject) + (    Dose+History|Nootropic), data=long)
  23. lmr6 <- lmer(Response ~       (1|Subject) + (Age+Dose+History|Nootropic), data=long)
  24. # lmr4 is best (Age drops out but we keep Subjects, Dose & History):
  25. anova(lmr1, lmr2, lmr3, lmr4, lmr5, lmr6)
  26.      Df  AIC  BIC logLik deviance Chisq Chi Df Pr(>Chisq)
  27. lmr1  4 5036 5056  -2514     5028
  28. lmr2  6 3555 3583  -1772     3543  1484      2     <2e-16
  29. lmr3  6 3854 3883  -1921     3842     0      0          1
  30. lmr4  9 2893 2933  -1437     2875   967      3     <2e-16
  31. lmr5 10 3006 3050  -1493     2986     0      1          1
  32. lmr6 13 3064 3121  -1519     3038     0      3          1
  33.  
  34. summary(lmr4)
  35. ...
  36. Random effects:
  37.  Groups    Name        Variance Std.Dev. Corr
  38.  Subject   (Intercept) 6.29e+00 2.507269
  39.  Nootropic (Intercept) 4.29e+00 2.070161
  40.            Dose        6.97e-08 0.000264 -1.000
  41.            History     4.39e-06 0.002096 -0.797  0.797
  42.  Residual              3.18e+00 1.783544
  43. Number of obs: 639, groups: Subject, 121; Nootropic, 27
  44.  
  45. Fixed effects:
  46.             Estimate Std. Error t value
  47. (Intercept)     5.47       0.34    16.1
  48.  
  49. rr1 <- ranef(lmr1, postVar=TRUE)
  50. rr4 <- ranef(lmr4, postVar=TRUE)
  51. noots4 <- rr4$Nootropic
  52. noots4[order(noots4$'(Intercept)'), , drop = FALSE]
  53.                           (Intercept)       Dose    History
  54. GingkoExperience             -3.11497  3.973e-04  3.884e-03
  55. DMAEExperience               -2.32433  2.964e-04  1.666e-03
  56. VitaminDExperience           -2.15718  2.751e-04  4.044e-04
  57. ALCARExperience              -1.44127  1.838e-04  1.150e-03
  58. PiracetamExperience          -1.36419  1.740e-04  1.917e-03
  59. VinpocetineExperience        -1.25651  1.603e-04  1.197e-03
  60. BacopaExperience             -1.18497  1.511e-04  1.837e-03
  61. LionapossManeExperience      -1.15578  1.474e-04  9.508e-04
  62. HordenineExperience          -1.15456  1.472e-04  9.246e-04
  63. SulbutiamineExperience       -1.04894  1.338e-04  1.335e-03
  64. HuperzineExperience          -0.76957  9.815e-05  7.428e-04
  65. GinsengExperience            -0.42476  5.417e-05  6.865e-04
  66. AniracetamExperience         -0.30357  3.872e-05  1.129e-03
  67. NoopeptExperience            -0.29668  3.784e-05  7.789e-04
  68. CentrophenoxineExperience    -0.19564  2.495e-05  1.389e-04
  69. OxiracetamExperience         -0.14437  1.841e-05  4.861e-04
  70. CreatineExperience           -0.12480  1.592e-05 -6.631e-04
  71. AshwagandhaExperience        -0.12103  1.544e-05 -5.619e-05
  72. PramiracetamExperience        0.03029 -3.863e-06  3.963e-04
  73. RhodiolaExperience            0.21512 -2.744e-05  1.100e-04
  74. PhenylpiracetamExperience     0.21959 -2.801e-05  1.032e-04
  75. ColuracetamExperience         0.35140 -4.482e-05 -9.800e-05
  76. AdrafinilExperience           0.48123 -6.137e-05 -2.582e-04
  77. TheanineExperience            0.49004 -6.250e-05 -1.659e-05
  78. CaffeineExperience            1.04602 -1.334e-04  1.169e-04
  79. ModafinilExperience           2.47240 -3.153e-04 -5.729e-04
  80. ArmodafinilExperience         2.83790 -3.619e-04 -2.132e-03
  81.  
  82. qq4 <- qqmath(rr4)
  83. # http://i.imgur.com/aQu8Igv.png
  84. qq4$Nootropic
  85.  
  86. # Like before, compare simple nootropics analysis with dose+history+nootropics:
  87. # what changed the most in absolute terms (least to greatest)?
  88. tmp <- merge(rr1$Nootropic, rr4$Nootropic[1], by="row.names", all=T)
  89. tmpDelta <- abs(tmp$"(Intercept).x" - tmp$"(Intercept).y")
  90. tmp[order(tmpDelta), , drop = FALSE]
  91.                    Row.names (Intercept).x (Intercept).y
  92. 20       ModafinilExperience       2.40961       2.47240
  93. 17       HuperzineExperience      -0.70487      -0.76957
  94. 8  CentrophenoxineExperience      -0.30221      -0.19564
  95. 1        AdrafinilExperience       0.59810       0.48123
  96. 28        TheanineExperience       0.64818       0.49004
  97. 5      AshwagandhaExperience       0.09079      -0.12103
  98. 26        RhodiolaExperience       0.46314       0.21512
  99. 22      OxiracetamExperience       0.11794      -0.14437
  100. 16       HordenineExperience      -0.88016      -1.15456
  101. 4      ArmodafinilExperience       2.53205       2.83790
  102. 23 PhenylpiracetamExperience       0.52651       0.21959
  103. 25    PramiracetamExperience       0.39316       0.03029
  104. 11     ColuracetamExperience       0.71994       0.35140
  105. 30     VinpocetineExperience      -0.87629      -1.25651
  106. 3       AniracetamExperience       0.12498      -0.30357
  107. 12        CreatineExperience       0.31701      -0.12480
  108. 18   LionapossManeExperience      -0.70730      -1.15578
  109. 21         NoopeptExperience       0.19493      -0.29668
  110. 13            DMAEExperience      -1.81606      -2.32433
  111. 7         CaffeineExperience       1.59909       1.04602
  112. 15         GinsengExperience      -1.12405      -0.42476
  113. 6           BacopaExperience      -0.40310      -1.18497
  114. 2            ALCARExperience      -0.59846      -1.44127
  115. 27    SulbutiamineExperience      -0.02826      -1.04894
  116. 14          GingkoExperience      -1.84778      -3.11497
  117. 24       PiracetamExperience      -0.09529      -1.36419
  118. 31        VitaminDExperience      -0.47647      -2.15718
Advertisement
RAW Paste Data Copied
Advertisement