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