Data cleaning

Select feature subset & impute missing data

Features chosen based on neuropsych related to INC/HA in context of frontostriatal model (c.f. Bragdon & Coles). Only features with less than 20% missingness were included.

##                                                                   pobs
## AST.Congruency.cost..Mean..correct.                          0.5838926
## AST.Switching.cost..Mean..correct.                           0.5973154
## AST.Mean.correct.latency                                     0.5973154
## AST.Mean.correct.latency..congruent.                         0.5973154
## AST.Mean.correct.latency..incongruent.                       0.5973154
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.5906040
## AST.Mean.correct.latency..block.7...switching.block.         0.5973154
## AST.Percent.correct.trials                                   0.5838926
## CGT.Delay.aversion                                           0.7852349
## CGT.Deliberation.time                                        0.7919463
## CGT.Overall.proportion.bet                                   0.7986577
## CGT.Quality.of.decision.making                               0.7852349
## CGT.Risk.adjustment                                          0.7919463
## CGT.Risk.taking                                              0.7986577
## PAL.First.trial.memory.score                                 0.9731544
## PAL.Stages.completed.on.first.trial                          0.9731544
## PAL.Total.errors..adjusted.                                  0.9194631
## PAL.Mean.errors.to.success                                   0.9664430
## PAL.Mean.trials.to.success                                   0.9597315
## PAL.Total.trials..adjusted.                                  0.9597315
## IED.Total.errors                                             0.9530201
## IED.Total.errors..adjusted.                                  0.9597315
## IED.Stages.completed                                         0.9597315
## IED.Completed.stage.errors                                   0.9597315
## IED.EDS.errors                                               0.9664430
## IED.Total.trials..adjusted.                                  0.9127517
## OTS.Mean.latency.to.correct                                  0.5234899
## OTS.Mean.latency.to.first.choice                             0.5167785
## OTS.Mean.choices.to.correct                                  0.5302013
## OTS.Problems.solved.on.first.choice                          0.5771812
## SRM.Mean.correct.latency                                     0.7382550
## SRM.Number.correct                                           0.7449664
## SRM.Percent.correct                                          0.7449664
## SSP.Number.of.attempts                                       0.7516779
## SSP.Span.length                                              0.7516779
## SSP.Mean.time.to.first.response                              0.7315436
## SSP.Total.errors                                             0.7315436
## SST.SSRT..last.half.                                         0.9664430
## SST.Mean.correct.RT.on.GO.trials                             0.9597315
## SST.Direction.errors.on.stop.and.go.trials                   0.9463087
## SST.Proportion.of.successful.stops..last.half.               0.9664430
## SST.SSD..50....last.half.                                    0.9664430
## RVP.A.                                                       0.5906040
## RVP.B..                                                      0.5906040
## RVP.Probability.of.hit                                       0.5973154
## RVP.Mean.latency                                             0.5771812
## RVP.Probability.of.false.alarm                               0.5771812
## Pt                                                           1.0000000
##                                                                   influx
## AST.Congruency.cost..Mean..correct.                          0.282478710
## AST.Switching.cost..Mean..correct.                           0.265446639
## AST.Mean.correct.latency                                     0.265446639
## AST.Mean.correct.latency..congruent.                         0.265446639
## AST.Mean.correct.latency..incongruent.                       0.265446639
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.273237905
## AST.Mean.correct.latency..block.7...switching.block.         0.265446639
## AST.Percent.correct.trials                                   0.281391556
## CGT.Delay.aversion                                           0.137887298
## CGT.Deliberation.time                                        0.127015764
## CGT.Overall.proportion.bet                                   0.122485958
## CGT.Quality.of.decision.making                               0.138612067
## CGT.Risk.adjustment                                          0.130096032
## CGT.Risk.taking                                              0.122485958
## PAL.First.trial.memory.score                                 0.008153651
## PAL.Stages.completed.on.first.trial                          0.008153651
## PAL.Total.errors..adjusted.                                  0.063054901
## PAL.Mean.errors.to.success                                   0.014676572
## PAL.Mean.trials.to.success                                   0.020112339
## PAL.Total.trials..adjusted.                                  0.020112339
## IED.Total.errors                                             0.029534336
## IED.Total.errors..adjusted.                                  0.025366914
## IED.Stages.completed                                         0.025366914
## IED.Completed.stage.errors                                   0.025366914
## IED.EDS.errors                                               0.018481609
## IED.Total.trials..adjusted.                                  0.064685631
## OTS.Mean.latency.to.correct                                  0.338285921
## OTS.Mean.latency.to.first.choice                             0.346801957
## OTS.Mean.choices.to.correct                                  0.331038232
## OTS.Problems.solved.on.first.choice                          0.277948904
## SRM.Mean.correct.latency                                     0.143504258
## SRM.Number.correct                                           0.134988223
## SRM.Percent.correct                                          0.134988223
## SSP.Number.of.attempts                                       0.131726762
## SSP.Span.length                                              0.131726762
## SSP.Mean.time.to.first.response                              0.153832216
## SSP.Total.errors                                             0.154375793
## SST.SSRT..last.half.                                         0.018481609
## SST.Mean.correct.RT.on.GO.trials                             0.027903606
## SST.Direction.errors.on.stop.and.go.trials                   0.041130640
## SST.Proportion.of.successful.stops..last.half.               0.018481609
## SST.SSD..50....last.half.                                    0.018481609
## RVP.A.                                                       0.271425983
## RVP.B..                                                      0.271425983
## RVP.Probability.of.hit                                       0.263272332
## RVP.Mean.latency                                             0.285921363
## RVP.Probability.of.false.alarm                               0.286827324
## Pt                                                           0.000000000
##                                                                 outflux
## AST.Congruency.cost..Mean..correct.                          0.13227189
## AST.Switching.cost..Mean..correct.                           0.13349663
## AST.Mean.correct.latency                                     0.13349663
## AST.Mean.correct.latency..congruent.                         0.13349663
## AST.Mean.correct.latency..incongruent.                       0.13349663
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.13043478
## AST.Mean.correct.latency..block.7...switching.block.         0.13349663
## AST.Percent.correct.trials                                   0.12859767
## CGT.Delay.aversion                                           0.52541335
## CGT.Deliberation.time                                        0.51806491
## CGT.Overall.proportion.bet                                   0.53214942
## CGT.Quality.of.decision.making                               0.52786283
## CGT.Risk.adjustment                                          0.52847520
## CGT.Risk.taking                                              0.53214942
## PAL.First.trial.memory.score                                 0.90998163
## PAL.Stages.completed.on.first.trial                          0.90998163
## PAL.Total.errors..adjusted.                                  0.86037967
## PAL.Mean.errors.to.success                                   0.90263319
## PAL.Mean.trials.to.success                                   0.89161053
## PAL.Total.trials..adjusted.                                  0.89161053
## IED.Total.errors                                             0.89406001
## IED.Total.errors..adjusted.                                  0.90936926
## IED.Stages.completed                                         0.90936926
## IED.Completed.stage.errors                                   0.90936926
## IED.EDS.errors                                               0.91549296
## IED.Total.trials..adjusted.                                  0.83649724
## OTS.Mean.latency.to.correct                                  0.05633803
## OTS.Mean.latency.to.first.choice                             0.05572566
## OTS.Mean.choices.to.correct                                  0.06123699
## OTS.Problems.solved.on.first.choice                          0.08756889
## SRM.Mean.correct.latency                                     0.33864054
## SRM.Number.correct                                           0.33925291
## SRM.Percent.correct                                          0.33925291
## SSP.Number.of.attempts                                       0.35762400
## SSP.Span.length                                              0.35762400
## SSP.Mean.time.to.first.response                              0.34415187
## SSP.Total.errors                                             0.34598898
## SST.SSRT..last.half.                                         0.91549296
## SST.Mean.correct.RT.on.GO.trials                             0.91794244
## SST.Direction.errors.on.stop.and.go.trials                   0.90385793
## SST.Proportion.of.successful.stops..last.half.               0.91549296
## SST.SSD..50....last.half.                                    0.91549296
## RVP.A.                                                       0.12431108
## RVP.B..                                                      0.12431108
## RVP.Probability.of.hit                                       0.12614819
## RVP.Mean.latency                                             0.11451317
## RVP.Probability.of.false.alarm                               0.11757502
## Pt                                                           1.00000000
##                                                                   ainb
## AST.Congruency.cost..Mean..correct.                          0.5350034
## AST.Switching.cost..Mean..correct.                           0.5195035
## AST.Mean.correct.latency                                     0.5195035
## AST.Mean.correct.latency..congruent.                         0.5195035
## AST.Mean.correct.latency..incongruent.                       0.5195035
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.5259854
## AST.Mean.correct.latency..block.7...switching.block.         0.5195035
## AST.Percent.correct.trials                                   0.5329444
## CGT.Delay.aversion                                           0.5059840
## CGT.Deliberation.time                                        0.4811256
## CGT.Overall.proportion.bet                                   0.4794326
## CGT.Quality.of.decision.making                               0.5086436
## CGT.Risk.adjustment                                          0.4927934
## CGT.Risk.taking                                              0.4794326
## PAL.First.trial.memory.score                                 0.2393617
## PAL.Stages.completed.on.first.trial                          0.2393617
## PAL.Total.errors..adjusted.                                  0.6170213
## PAL.Mean.errors.to.success                                   0.3446809
## PAL.Mean.trials.to.success                                   0.3936170
## PAL.Total.trials..adjusted.                                  0.3936170
## IED.Total.errors                                             0.4954407
## IED.Total.errors..adjusted.                                  0.4964539
## IED.Stages.completed                                         0.4964539
## IED.Completed.stage.errors                                   0.4964539
## IED.EDS.errors                                               0.4340426
## IED.Total.trials..adjusted.                                  0.5842881
## OTS.Mean.latency.to.correct                                  0.5594846
## OTS.Mean.latency.to.first.choice                             0.5656028
## OTS.Mean.choices.to.correct                                  0.5553191
## OTS.Problems.solved.on.first.choice                          0.5180682
## SRM.Mean.correct.latency                                     0.4320786
## SRM.Number.correct                                           0.4171333
## SRM.Percent.correct                                          0.4171333
## SSP.Number.of.attempts                                       0.4180564
## SSP.Span.length                                              0.4180564
## SSP.Mean.time.to.first.response                              0.4515957
## SSP.Total.errors                                             0.4531915
## SST.SSRT..last.half.                                         0.4340426
## SST.Mean.correct.RT.on.GO.trials                             0.5460993
## SST.Direction.errors.on.stop.and.go.trials                   0.6037234
## SST.Proportion.of.successful.stops..last.half.               0.4340426
## SST.SSD..50....last.half.                                    0.4340426
## RVP.A.                                                       0.5224974
## RVP.B..                                                      0.5224974
## RVP.Probability.of.hit                                       0.5152482
## RVP.Mean.latency                                             0.5329281
## RVP.Probability.of.false.alarm                               0.5346167
## Pt                                                           0.0000000
##                                                                    aout
## AST.Congruency.cost..Mean..correct.                          0.05282465
## AST.Switching.cost..Mean..correct.                           0.05211571
## AST.Mean.correct.latency                                     0.05211571
## AST.Mean.correct.latency..congruent.                         0.05211571
## AST.Mean.correct.latency..incongruent.                       0.05211571
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.05149903
## AST.Mean.correct.latency..block.7...switching.block.         0.05211571
## AST.Percent.correct.trials                                   0.05135730
## CGT.Delay.aversion                                           0.15602837
## CGT.Deliberation.time                                        0.15254237
## CGT.Overall.proportion.bet                                   0.15537279
## CGT.Quality.of.decision.making                               0.15675577
## CGT.Risk.adjustment                                          0.15560765
## CGT.Risk.taking                                              0.15537279
## PAL.First.trial.memory.score                                 0.21804842
## PAL.Stages.completed.on.first.trial                          0.21804842
## PAL.Total.errors..adjusted.                                  0.21820158
## PAL.Mean.errors.to.success                                   0.21778960
## PAL.Mean.trials.to.success                                   0.21663443
## PAL.Total.trials..adjusted.                                  0.21663443
## IED.Total.errors                                             0.21875936
## IED.Total.errors..adjusted.                                  0.22094926
## IED.Stages.completed                                         0.22094926
## IED.Completed.stage.errors                                   0.22094926
## IED.EDS.errors                                               0.22089243
## IED.Total.trials..adjusted.                                  0.21370463
## OTS.Mean.latency.to.correct                                  0.02509547
## OTS.Mean.latency.to.first.choice                             0.02514507
## OTS.Mean.choices.to.correct                                  0.02693240
## OTS.Problems.solved.on.first.choice                          0.03537853
## SRM.Mean.correct.latency                                     0.10696325
## SRM.Number.correct                                           0.10619130
## SRM.Percent.correct                                          0.10619130
## SSP.Number.of.attempts                                       0.11094225
## SSP.Span.length                                              0.11094225
## SSP.Mean.time.to.first.response                              0.10970135
## SSP.Total.errors                                             0.11028694
## SST.SSRT..last.half.                                         0.22089243
## SST.Mean.correct.RT.on.GO.trials                             0.22303229
## SST.Direction.errors.on.stop.and.go.trials                   0.22272522
## SST.Proportion.of.successful.stops..last.half.               0.22089243
## SST.SSD..50....last.half.                                    0.22089243
## RVP.A.                                                       0.04908124
## RVP.B..                                                      0.04908124
## RVP.Probability.of.hit                                       0.04924695
## RVP.Mean.latency                                             0.04626423
## RVP.Probability.of.false.alarm                               0.04750124
## Pt                                                           0.23318578
##                                                                   fico
## AST.Congruency.cost..Mean..correct.                          0.4252874
## AST.Switching.cost..Mean..correct.                           0.4382022
## AST.Mean.correct.latency                                     0.4382022
## AST.Mean.correct.latency..congruent.                         0.4382022
## AST.Mean.correct.latency..incongruent.                       0.4382022
## AST.Mean.correct.latency..blocks.3.5...non.switching.blocks. 0.4318182
## AST.Mean.correct.latency..block.7...switching.block.         0.4382022
## AST.Percent.correct.trials                                   0.4252874
## CGT.Delay.aversion                                           0.5726496
## CGT.Deliberation.time                                        0.5762712
## CGT.Overall.proportion.bet                                   0.5798319
## CGT.Quality.of.decision.making                               0.5726496
## CGT.Risk.adjustment                                          0.5762712
## CGT.Risk.taking                                              0.5798319
## PAL.First.trial.memory.score                                 0.6551724
## PAL.Stages.completed.on.first.trial                          0.6551724
## PAL.Total.errors..adjusted.                                  0.6350365
## PAL.Mean.errors.to.success                                   0.6527778
## PAL.Mean.trials.to.success                                   0.6503497
## PAL.Total.trials..adjusted.                                  0.6503497
## IED.Total.errors                                             0.6478873
## IED.Total.errors..adjusted.                                  0.6503497
## IED.Stages.completed                                         0.6503497
## IED.Completed.stage.errors                                   0.6503497
## IED.EDS.errors                                               0.6527778
## IED.Total.trials..adjusted.                                  0.6323529
## OTS.Mean.latency.to.correct                                  0.3589744
## OTS.Mean.latency.to.first.choice                             0.3506494
## OTS.Mean.choices.to.correct                                  0.3670886
## OTS.Problems.solved.on.first.choice                          0.4186047
## SRM.Mean.correct.latency                                     0.5454545
## SRM.Number.correct                                           0.5495495
## SRM.Percent.correct                                          0.5495495
## SSP.Number.of.attempts                                       0.5535714
## SSP.Span.length                                              0.5535714
## SSP.Mean.time.to.first.response                              0.5412844
## SSP.Total.errors                                             0.5412844
## SST.SSRT..last.half.                                         0.6527778
## SST.Mean.correct.RT.on.GO.trials                             0.6503497
## SST.Direction.errors.on.stop.and.go.trials                   0.6453901
## SST.Proportion.of.successful.stops..last.half.               0.6527778
## SST.SSD..50....last.half.                                    0.6527778
## RVP.A.                                                       0.4318182
## RVP.B..                                                      0.4318182
## RVP.Probability.of.hit                                       0.4382022
## RVP.Mean.latency                                             0.4186047
## RVP.Probability.of.false.alarm                               0.4186047
## Pt                                                           0.6644295

## 
##  iter imp variable
##   1   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Total.errors..adjusted.  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Stages.completed  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
## 
##  iter imp variable
##   1   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   1   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   2   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   3   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   4   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   1  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   2  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   3  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   4  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.
##   5   5  CGT.Delay.aversion  CGT.Deliberation.time  CGT.Overall.proportion.bet  CGT.Quality.of.decision.making  CGT.Risk.adjustment  CGT.Risk.taking  PAL.First.trial.memory.score  PAL.Stages.completed.on.first.trial  PAL.Mean.errors.to.success  PAL.Mean.trials.to.success  PAL.Total.trials..adjusted.  IED.Total.errors  IED.Total.errors..adjusted.  IED.Completed.stage.errors  IED.EDS.errors  IED.Total.trials..adjusted.  SST.SSRT..last.half.  SST.Mean.correct.RT.on.GO.trials  SST.Direction.errors.on.stop.and.go.trials  SST.Proportion.of.successful.stops..last.half.  SST.SSD..50....last.half.

Plot distributions of original and imputed data

temat.cog.fs.flux.2%>%
  keep(is.numeric) %>%                     # Keep only numeric columns
  gather() %>%                             # Convert to key-value pairs
  ggplot(aes(value)) +                     # Plot the values
    facet_wrap(~ key, scales = "free") +   # In separate panels
    geom_density() 

temat.cog.fs.flux.2.imputed %>%
  keep(is.numeric) %>%                     # Keep only numeric columns
  gather() %>%                             # Convert to key-value pairs
  ggplot(aes(value)) +                     # Plot the values
    facet_wrap(~ key, scales = "free") +   # In separate panels
    geom_density() 

Testing predictability of OCD patients with and without sensory phenomena

Random Forest

set.seed(321)
split = sample.split(temat.cog.fs.flux.2.imputed$SPSPtCtrl, SplitRatio = 0.70) 

TrainSet = subset(temat.cog.fs.flux.2.imputed, split == TRUE) 
ValidSet = subset(temat.cog.fs.flux.2.imputed, split == FALSE) 
 
TrainSet$SPSPtCtrl <- as.factor(as.character(TrainSet$SPSPtCtrl))
ValidSet$SPSPtCtrl <- as.factor(as.character(ValidSet$SPSPtCtrl))

#verify the distribution of 0s/1s in the training/validation sets
prop.table(table(TrainSet$SPSPtCtrl)) * 100
## 
##        0        1        2 
## 44.08602 34.40860 21.50538
prop.table(table(ValidSet$SPSPtCtrl)) * 100
## 
##        0        1        2 
## 43.90244 34.14634 21.95122
# 3-fold CV with caret
control <- trainControl(method="cv", number=3, search="random", savePredictions = "final")

# Tune to determine optimal ntree
set.seed(321)
tunegrid <- expand.grid(.mtry=c(sqrt(ncol(TrainSet))))
modellist <- list()

for (ntree in c(51, 101, 501,601,701,801,901,1001,1101,1201)) {
    set.seed(321)
    fit <- train(SPSPtCtrl~., data=TrainSet, method="rf", tuneGrid=tunegrid, trControl=control, ntree=ntree)
    key <- toString(ntree)
    modellist[[key]] <- fit
}
modellist # highest accuracy: 51 trees
## $`51`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4404794  0.08641557
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`101`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4293683  0.06458938
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`501`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.3977823  0.01494571
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`601`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4085349  0.03482068
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`701`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.3974238  0.01306122
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`801`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.3974238  0.01115966
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`901`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.3974238  0.01115966
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1001`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4081765  0.02486876
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1101`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4189292  0.04162266
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1201`
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.4189292  0.04162266
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
set.seed(321)
rf_random <- train(SPSPtCtrl~., data=TrainSet, method="rf", tuneLength=3, trControl=control, ntree=51)
print(rf_random)
## Random Forest 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa     
##   13    0.4081765  0.04336851
##   16    0.4730959  0.14946963
##   17    0.5057348  0.20234960
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 17.
confusionMatrix(rf_random$pred[order(rf_random$pred$rowIndex),2], TrainSet$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 27 10  9
##          1 11 18  9
##          2  3  4  2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.5054          
##                  95% CI : (0.3997, 0.6107)
##     No Information Rate : 0.4409          
##     P-Value [Acc > NIR] : 0.1255          
##                                           
##                   Kappa : 0.2029          
##                                           
##  Mcnemar's Test P-Value : 0.1740          
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.5870   0.4737  0.22222
## Recall                 0.6585   0.5625  0.10000
## F1                     0.6207   0.5143  0.13793
## Prevalence             0.4409   0.3441  0.21505
## Detection Rate         0.2903   0.1935  0.02151
## Detection Prevalence   0.4946   0.4086  0.09677
## Balanced Accuracy      0.6466   0.6173  0.50205
pred_1 = predict(rf_random, ValidSet, type="raw")

confusionMatrix(pred_1, ValidSet$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 11  3  2
##          1  5  8  4
##          2  2  3  3
## 
## Overall Statistics
##                                           
##                Accuracy : 0.5366          
##                  95% CI : (0.3742, 0.6934)
##     No Information Rate : 0.439           
##     P-Value [Acc > NIR] : 0.1355          
##                                           
##                   Kappa : 0.2807          
##                                           
##  Mcnemar's Test P-Value : 0.8866          
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.6875   0.4706  0.37500
## Recall                 0.6111   0.5714  0.33333
## F1                     0.6471   0.5161  0.35294
## Prevalence             0.4390   0.3415  0.21951
## Detection Rate         0.2683   0.1951  0.07317
## Detection Prevalence   0.3902   0.4146  0.19512
## Balanced Accuracy      0.6969   0.6190  0.58854
#variable importance
vi.rf.temat <- varImp(rf_random, scale = T, useModel = TRUE)
plot(vi.rf.temat)

Support Vector Machine

#splitting the data set into the Training set and Test set 
set.seed(321) 
split = sample.split(temat.cog.fs.flux.2.imputed$SPSPtCtrl, SplitRatio = 0.70) 

training_set = subset(temat.cog.fs.flux.2.imputed, split == TRUE) 
test_set = subset(temat.cog.fs.flux.2.imputed, split == FALSE) 

training_set$SPSPtCtrl <- as.factor(training_set$SPSPtCtrl)
test_set$SPSPtCtrl <- as.factor(test_set$SPSPtCtrl)

#feature scaling 
training_set[-22] = scale(training_set[-22]) 
test_set[-22] = scale(test_set[-22]) 

prop.table(table(training_set$SPSPtCtrl)) * 100
## 
##        0        1        2 
## 44.08602 34.40860 21.50538
prop.table(table(test_set$SPSPtCtrl)) * 100
## 
##        0        1        2 
## 43.90244 34.14634 21.95122
#find optimal tuning parameters for svm
#Caret limited to tuning 1 parameter at a time - manually loop through
trainacc = c() 
testacc = c() 
kernel_list <- list("linear", "polynomial", "radial", "sigmoid")
cost_list <- list(.5,1,1.5, 2, 2.5,3,3.5) # these values are after having zeroed in on optimal cost parameter range
gamma_list <- list(0.125,0.25,0.5,1,2,4,8,16)

n <- 1
for (k in seq_along(kernel_list)){
  for (j in seq_along(cost_list)){
    for (i in seq_along(gamma_list)){
      set.seed(321)
      #run model with selected tuning parameters
      svm_model_cs_tuned <- svm(SPSPtCtrl~ ., data=training_set, method="C-classification", kernel=kernel_list[[k]],cost=cost_list[[j]],gamma=gamma_list[[i]])
      #training set predictions
      pred_train <-predict(svm_model_cs_tuned,training_set)
      mean(pred_train==training_set$SPSPtCtrl)
      trainacc[n] <- mean(pred_train==training_set$SPSPtCtrl)
      #test set predictions
      pred_test <-predict(svm_model_cs_tuned,test_set)
      testacc[n] <- mean(pred_test==test_set$SPSPtCtrl)
      
      n <- n+1
    }
  }
}

#examine train and test accuracy side by side
kernels <- c(rep("linear",56),rep("polynomial",56),rep("radial",56),rep("sigmoid",56))
costprep <- c(rep(".051",8), rep(".052",8),rep(".053",8),rep(".054",8),rep(".055",8),rep(".056",8),rep(".057",8))
costs <- rep(costprep,4)
gammasprep <- c(0.125,0.25,0.5,1,2,4,8,16)
gammas <- c(rep(gammasprep, 28))
accuracytable <- cbind(trainacc, testacc, kernels, gammas, costs)
accuracytable
##        trainacc            testacc             kernels      gammas  costs 
##   [1,] "0.666666666666667" "0.439024390243902" "linear"     "0.125" ".051"
##   [2,] "0.666666666666667" "0.439024390243902" "linear"     "0.25"  ".051"
##   [3,] "0.666666666666667" "0.439024390243902" "linear"     "0.5"   ".051"
##   [4,] "0.666666666666667" "0.439024390243902" "linear"     "1"     ".051"
##   [5,] "0.666666666666667" "0.439024390243902" "linear"     "2"     ".051"
##   [6,] "0.666666666666667" "0.439024390243902" "linear"     "4"     ".051"
##   [7,] "0.666666666666667" "0.439024390243902" "linear"     "8"     ".051"
##   [8,] "0.666666666666667" "0.439024390243902" "linear"     "16"    ".051"
##   [9,] "0.645161290322581" "0.390243902439024" "linear"     "0.125" ".052"
##  [10,] "0.645161290322581" "0.390243902439024" "linear"     "0.25"  ".052"
##  [11,] "0.645161290322581" "0.390243902439024" "linear"     "0.5"   ".052"
##  [12,] "0.645161290322581" "0.390243902439024" "linear"     "1"     ".052"
##  [13,] "0.645161290322581" "0.390243902439024" "linear"     "2"     ".052"
##  [14,] "0.645161290322581" "0.390243902439024" "linear"     "4"     ".052"
##  [15,] "0.645161290322581" "0.390243902439024" "linear"     "8"     ".052"
##  [16,] "0.645161290322581" "0.390243902439024" "linear"     "16"    ".052"
##  [17,] "0.666666666666667" "0.390243902439024" "linear"     "0.125" ".053"
##  [18,] "0.666666666666667" "0.390243902439024" "linear"     "0.25"  ".053"
##  [19,] "0.666666666666667" "0.390243902439024" "linear"     "0.5"   ".053"
##  [20,] "0.666666666666667" "0.390243902439024" "linear"     "1"     ".053"
##  [21,] "0.666666666666667" "0.390243902439024" "linear"     "2"     ".053"
##  [22,] "0.666666666666667" "0.390243902439024" "linear"     "4"     ".053"
##  [23,] "0.666666666666667" "0.390243902439024" "linear"     "8"     ".053"
##  [24,] "0.666666666666667" "0.390243902439024" "linear"     "16"    ".053"
##  [25,] "0.67741935483871"  "0.390243902439024" "linear"     "0.125" ".054"
##  [26,] "0.67741935483871"  "0.390243902439024" "linear"     "0.25"  ".054"
##  [27,] "0.67741935483871"  "0.390243902439024" "linear"     "0.5"   ".054"
##  [28,] "0.67741935483871"  "0.390243902439024" "linear"     "1"     ".054"
##  [29,] "0.67741935483871"  "0.390243902439024" "linear"     "2"     ".054"
##  [30,] "0.67741935483871"  "0.390243902439024" "linear"     "4"     ".054"
##  [31,] "0.67741935483871"  "0.390243902439024" "linear"     "8"     ".054"
##  [32,] "0.67741935483871"  "0.390243902439024" "linear"     "16"    ".054"
##  [33,] "0.666666666666667" "0.365853658536585" "linear"     "0.125" ".055"
##  [34,] "0.666666666666667" "0.365853658536585" "linear"     "0.25"  ".055"
##  [35,] "0.666666666666667" "0.365853658536585" "linear"     "0.5"   ".055"
##  [36,] "0.666666666666667" "0.365853658536585" "linear"     "1"     ".055"
##  [37,] "0.666666666666667" "0.365853658536585" "linear"     "2"     ".055"
##  [38,] "0.666666666666667" "0.365853658536585" "linear"     "4"     ".055"
##  [39,] "0.666666666666667" "0.365853658536585" "linear"     "8"     ".055"
##  [40,] "0.666666666666667" "0.365853658536585" "linear"     "16"    ".055"
##  [41,] "0.67741935483871"  "0.317073170731707" "linear"     "0.125" ".056"
##  [42,] "0.67741935483871"  "0.317073170731707" "linear"     "0.25"  ".056"
##  [43,] "0.67741935483871"  "0.317073170731707" "linear"     "0.5"   ".056"
##  [44,] "0.67741935483871"  "0.317073170731707" "linear"     "1"     ".056"
##  [45,] "0.67741935483871"  "0.317073170731707" "linear"     "2"     ".056"
##  [46,] "0.67741935483871"  "0.317073170731707" "linear"     "4"     ".056"
##  [47,] "0.67741935483871"  "0.317073170731707" "linear"     "8"     ".056"
##  [48,] "0.67741935483871"  "0.317073170731707" "linear"     "16"    ".056"
##  [49,] "0.666666666666667" "0.341463414634146" "linear"     "0.125" ".057"
##  [50,] "0.666666666666667" "0.341463414634146" "linear"     "0.25"  ".057"
##  [51,] "0.666666666666667" "0.341463414634146" "linear"     "0.5"   ".057"
##  [52,] "0.666666666666667" "0.341463414634146" "linear"     "1"     ".057"
##  [53,] "0.666666666666667" "0.341463414634146" "linear"     "2"     ".057"
##  [54,] "0.666666666666667" "0.341463414634146" "linear"     "4"     ".057"
##  [55,] "0.666666666666667" "0.341463414634146" "linear"     "8"     ".057"
##  [56,] "0.666666666666667" "0.341463414634146" "linear"     "16"    ".057"
##  [57,] "0.924731182795699" "0.414634146341463" "polynomial" "0.125" ".051"
##  [58,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".051"
##  [59,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".051"
##  [60,] "1"                 "0.414634146341463" "polynomial" "1"     ".051"
##  [61,] "1"                 "0.414634146341463" "polynomial" "2"     ".051"
##  [62,] "1"                 "0.414634146341463" "polynomial" "4"     ".051"
##  [63,] "1"                 "0.414634146341463" "polynomial" "8"     ".051"
##  [64,] "1"                 "0.414634146341463" "polynomial" "16"    ".051"
##  [65,] "0.967741935483871" "0.390243902439024" "polynomial" "0.125" ".052"
##  [66,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".052"
##  [67,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".052"
##  [68,] "1"                 "0.414634146341463" "polynomial" "1"     ".052"
##  [69,] "1"                 "0.414634146341463" "polynomial" "2"     ".052"
##  [70,] "1"                 "0.414634146341463" "polynomial" "4"     ".052"
##  [71,] "1"                 "0.414634146341463" "polynomial" "8"     ".052"
##  [72,] "1"                 "0.414634146341463" "polynomial" "16"    ".052"
##  [73,] "0.989247311827957" "0.365853658536585" "polynomial" "0.125" ".053"
##  [74,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".053"
##  [75,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".053"
##  [76,] "1"                 "0.414634146341463" "polynomial" "1"     ".053"
##  [77,] "1"                 "0.414634146341463" "polynomial" "2"     ".053"
##  [78,] "1"                 "0.414634146341463" "polynomial" "4"     ".053"
##  [79,] "1"                 "0.414634146341463" "polynomial" "8"     ".053"
##  [80,] "1"                 "0.414634146341463" "polynomial" "16"    ".053"
##  [81,] "1"                 "0.390243902439024" "polynomial" "0.125" ".054"
##  [82,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".054"
##  [83,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".054"
##  [84,] "1"                 "0.414634146341463" "polynomial" "1"     ".054"
##  [85,] "1"                 "0.414634146341463" "polynomial" "2"     ".054"
##  [86,] "1"                 "0.414634146341463" "polynomial" "4"     ".054"
##  [87,] "1"                 "0.414634146341463" "polynomial" "8"     ".054"
##  [88,] "1"                 "0.414634146341463" "polynomial" "16"    ".054"
##  [89,] "1"                 "0.365853658536585" "polynomial" "0.125" ".055"
##  [90,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".055"
##  [91,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".055"
##  [92,] "1"                 "0.414634146341463" "polynomial" "1"     ".055"
##  [93,] "1"                 "0.414634146341463" "polynomial" "2"     ".055"
##  [94,] "1"                 "0.414634146341463" "polynomial" "4"     ".055"
##  [95,] "1"                 "0.414634146341463" "polynomial" "8"     ".055"
##  [96,] "1"                 "0.414634146341463" "polynomial" "16"    ".055"
##  [97,] "1"                 "0.414634146341463" "polynomial" "0.125" ".056"
##  [98,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".056"
##  [99,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".056"
## [100,] "1"                 "0.414634146341463" "polynomial" "1"     ".056"
## [101,] "1"                 "0.414634146341463" "polynomial" "2"     ".056"
## [102,] "1"                 "0.414634146341463" "polynomial" "4"     ".056"
## [103,] "1"                 "0.414634146341463" "polynomial" "8"     ".056"
## [104,] "1"                 "0.414634146341463" "polynomial" "16"    ".056"
## [105,] "1"                 "0.414634146341463" "polynomial" "0.125" ".057"
## [106,] "1"                 "0.414634146341463" "polynomial" "0.25"  ".057"
## [107,] "1"                 "0.414634146341463" "polynomial" "0.5"   ".057"
## [108,] "1"                 "0.414634146341463" "polynomial" "1"     ".057"
## [109,] "1"                 "0.414634146341463" "polynomial" "2"     ".057"
## [110,] "1"                 "0.414634146341463" "polynomial" "4"     ".057"
## [111,] "1"                 "0.414634146341463" "polynomial" "8"     ".057"
## [112,] "1"                 "0.414634146341463" "polynomial" "16"    ".057"
## [113,] "0.483870967741935" "0.439024390243902" "radial"     "0.125" ".051"
## [114,] "0.473118279569892" "0.439024390243902" "radial"     "0.25"  ".051"
## [115,] "0.440860215053763" "0.439024390243902" "radial"     "0.5"   ".051"
## [116,] "0.440860215053763" "0.439024390243902" "radial"     "1"     ".051"
## [117,] "0.440860215053763" "0.439024390243902" "radial"     "2"     ".051"
## [118,] "0.440860215053763" "0.439024390243902" "radial"     "4"     ".051"
## [119,] "0.440860215053763" "0.439024390243902" "radial"     "8"     ".051"
## [120,] "0.440860215053763" "0.439024390243902" "radial"     "16"    ".051"
## [121,] "0.881720430107527" "0.439024390243902" "radial"     "0.125" ".052"
## [122,] "0.989247311827957" "0.365853658536585" "radial"     "0.25"  ".052"
## [123,] "1"                 "0.439024390243902" "radial"     "0.5"   ".052"
## [124,] "1"                 "0.439024390243902" "radial"     "1"     ".052"
## [125,] "1"                 "0.439024390243902" "radial"     "2"     ".052"
## [126,] "1"                 "0.439024390243902" "radial"     "4"     ".052"
## [127,] "1"                 "0.439024390243902" "radial"     "8"     ".052"
## [128,] "1"                 "0.439024390243902" "radial"     "16"    ".052"
## [129,] "0.956989247311828" "0.414634146341463" "radial"     "0.125" ".053"
## [130,] "1"                 "0.414634146341463" "radial"     "0.25"  ".053"
## [131,] "1"                 "0.439024390243902" "radial"     "0.5"   ".053"
## [132,] "1"                 "0.439024390243902" "radial"     "1"     ".053"
## [133,] "1"                 "0.439024390243902" "radial"     "2"     ".053"
## [134,] "1"                 "0.439024390243902" "radial"     "4"     ".053"
## [135,] "1"                 "0.439024390243902" "radial"     "8"     ".053"
## [136,] "1"                 "0.439024390243902" "radial"     "16"    ".053"
## [137,] "0.989247311827957" "0.439024390243902" "radial"     "0.125" ".054"
## [138,] "1"                 "0.390243902439024" "radial"     "0.25"  ".054"
## [139,] "1"                 "0.439024390243902" "radial"     "0.5"   ".054"
## [140,] "1"                 "0.439024390243902" "radial"     "1"     ".054"
## [141,] "1"                 "0.439024390243902" "radial"     "2"     ".054"
## [142,] "1"                 "0.439024390243902" "radial"     "4"     ".054"
## [143,] "1"                 "0.439024390243902" "radial"     "8"     ".054"
## [144,] "1"                 "0.439024390243902" "radial"     "16"    ".054"
## [145,] "0.989247311827957" "0.439024390243902" "radial"     "0.125" ".055"
## [146,] "1"                 "0.390243902439024" "radial"     "0.25"  ".055"
## [147,] "1"                 "0.439024390243902" "radial"     "0.5"   ".055"
## [148,] "1"                 "0.439024390243902" "radial"     "1"     ".055"
## [149,] "1"                 "0.439024390243902" "radial"     "2"     ".055"
## [150,] "1"                 "0.439024390243902" "radial"     "4"     ".055"
## [151,] "1"                 "0.439024390243902" "radial"     "8"     ".055"
## [152,] "1"                 "0.439024390243902" "radial"     "16"    ".055"
## [153,] "1"                 "0.414634146341463" "radial"     "0.125" ".056"
## [154,] "1"                 "0.390243902439024" "radial"     "0.25"  ".056"
## [155,] "1"                 "0.439024390243902" "radial"     "0.5"   ".056"
## [156,] "1"                 "0.439024390243902" "radial"     "1"     ".056"
## [157,] "1"                 "0.439024390243902" "radial"     "2"     ".056"
## [158,] "1"                 "0.439024390243902" "radial"     "4"     ".056"
## [159,] "1"                 "0.439024390243902" "radial"     "8"     ".056"
## [160,] "1"                 "0.439024390243902" "radial"     "16"    ".056"
## [161,] "1"                 "0.439024390243902" "radial"     "0.125" ".057"
## [162,] "1"                 "0.390243902439024" "radial"     "0.25"  ".057"
## [163,] "1"                 "0.439024390243902" "radial"     "0.5"   ".057"
## [164,] "1"                 "0.439024390243902" "radial"     "1"     ".057"
## [165,] "1"                 "0.439024390243902" "radial"     "2"     ".057"
## [166,] "1"                 "0.439024390243902" "radial"     "4"     ".057"
## [167,] "1"                 "0.439024390243902" "radial"     "8"     ".057"
## [168,] "1"                 "0.439024390243902" "radial"     "16"    ".057"
## [169,] "0.494623655913978" "0.536585365853659" "sigmoid"    "0.125" ".051"
## [170,] "0.387096774193548" "0.51219512195122"  "sigmoid"    "0.25"  ".051"
## [171,] "0.376344086021505" "0.463414634146341" "sigmoid"    "0.5"   ".051"
## [172,] "0.268817204301075" "0.463414634146341" "sigmoid"    "1"     ".051"
## [173,] "0.311827956989247" "0.439024390243902" "sigmoid"    "2"     ".051"
## [174,] "0.333333333333333" "0.51219512195122"  "sigmoid"    "4"     ".051"
## [175,] "0.301075268817204" "0.463414634146341" "sigmoid"    "8"     ".051"
## [176,] "0.311827956989247" "0.48780487804878"  "sigmoid"    "16"    ".051"
## [177,] "0.387096774193548" "0.48780487804878"  "sigmoid"    "0.125" ".052"
## [178,] "0.236559139784946" "0.439024390243902" "sigmoid"    "0.25"  ".052"
## [179,] "0.258064516129032" "0.51219512195122"  "sigmoid"    "0.5"   ".052"
## [180,] "0.279569892473118" "0.536585365853659" "sigmoid"    "1"     ".052"
## [181,] "0.268817204301075" "0.48780487804878"  "sigmoid"    "2"     ".052"
## [182,] "0.279569892473118" "0.463414634146341" "sigmoid"    "4"     ".052"
## [183,] "0.279569892473118" "0.463414634146341" "sigmoid"    "8"     ".052"
## [184,] "0.333333333333333" "0.439024390243902" "sigmoid"    "16"    ".052"
## [185,] "0.32258064516129"  "0.51219512195122"  "sigmoid"    "0.125" ".053"
## [186,] "0.247311827956989" "0.414634146341463" "sigmoid"    "0.25"  ".053"
## [187,] "0.236559139784946" "0.48780487804878"  "sigmoid"    "0.5"   ".053"
## [188,] "0.247311827956989" "0.48780487804878"  "sigmoid"    "1"     ".053"
## [189,] "0.290322580645161" "0.536585365853659" "sigmoid"    "2"     ".053"
## [190,] "0.268817204301075" "0.48780487804878"  "sigmoid"    "4"     ".053"
## [191,] "0.301075268817204" "0.48780487804878"  "sigmoid"    "8"     ".053"
## [192,] "0.311827956989247" "0.463414634146341" "sigmoid"    "16"    ".053"
## [193,] "0.279569892473118" "0.51219512195122"  "sigmoid"    "0.125" ".054"
## [194,] "0.268817204301075" "0.536585365853659" "sigmoid"    "0.25"  ".054"
## [195,] "0.258064516129032" "0.51219512195122"  "sigmoid"    "0.5"   ".054"
## [196,] "0.247311827956989" "0.439024390243902" "sigmoid"    "1"     ".054"
## [197,] "0.247311827956989" "0.536585365853659" "sigmoid"    "2"     ".054"
## [198,] "0.32258064516129"  "0.51219512195122"  "sigmoid"    "4"     ".054"
## [199,] "0.301075268817204" "0.48780487804878"  "sigmoid"    "8"     ".054"
## [200,] "0.365591397849462" "0.463414634146341" "sigmoid"    "16"    ".054"
## [201,] "0.32258064516129"  "0.48780487804878"  "sigmoid"    "0.125" ".055"
## [202,] "0.279569892473118" "0.439024390243902" "sigmoid"    "0.25"  ".055"
## [203,] "0.279569892473118" "0.463414634146341" "sigmoid"    "0.5"   ".055"
## [204,] "0.268817204301075" "0.439024390243902" "sigmoid"    "1"     ".055"
## [205,] "0.268817204301075" "0.51219512195122"  "sigmoid"    "2"     ".055"
## [206,] "0.32258064516129"  "0.51219512195122"  "sigmoid"    "4"     ".055"
## [207,] "0.258064516129032" "0.48780487804878"  "sigmoid"    "8"     ".055"
## [208,] "0.344086021505376" "0.48780487804878"  "sigmoid"    "16"    ".055"
## [209,] "0.333333333333333" "0.560975609756098" "sigmoid"    "0.125" ".056"
## [210,] "0.301075268817204" "0.51219512195122"  "sigmoid"    "0.25"  ".056"
## [211,] "0.268817204301075" "0.51219512195122"  "sigmoid"    "0.5"   ".056"
## [212,] "0.236559139784946" "0.51219512195122"  "sigmoid"    "1"     ".056"
## [213,] "0.290322580645161" "0.439024390243902" "sigmoid"    "2"     ".056"
## [214,] "0.32258064516129"  "0.51219512195122"  "sigmoid"    "4"     ".056"
## [215,] "0.258064516129032" "0.439024390243902" "sigmoid"    "8"     ".056"
## [216,] "0.365591397849462" "0.48780487804878"  "sigmoid"    "16"    ".056"
## [217,] "0.301075268817204" "0.48780487804878"  "sigmoid"    "0.125" ".057"
## [218,] "0.258064516129032" "0.414634146341463" "sigmoid"    "0.25"  ".057"
## [219,] "0.268817204301075" "0.51219512195122"  "sigmoid"    "0.5"   ".057"
## [220,] "0.268817204301075" "0.463414634146341" "sigmoid"    "1"     ".057"
## [221,] "0.301075268817204" "0.439024390243902" "sigmoid"    "2"     ".057"
## [222,] "0.32258064516129"  "0.51219512195122"  "sigmoid"    "4"     ".057"
## [223,] "0.258064516129032" "0.439024390243902" "sigmoid"    "8"     ".057"
## [224,] "0.365591397849462" "0.48780487804878"  "sigmoid"    "16"    ".057"
# run model using best cost, gamma, kernel and cross-validation
set.seed(321)
svm_model_cs_tuned <- svm(SPSPtCtrl~ ., data=training_set, method="C-classification", kernel="linear",cost=.054, cross=3)

#training set predictions
pred_train <-predict(svm_model_cs_tuned,training_set)
mean(pred_train==training_set$SPSPtCtrl)
## [1] 0.6021505
confusionMatrix(pred_train,training_set$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 37 15 14
##          1  4 17  4
##          2  0  0  2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.6022          
##                  95% CI : (0.4954, 0.7022)
##     No Information Rate : 0.4409          
##     P-Value [Acc > NIR] : 0.001276        
##                                           
##                   Kappa : 0.3257          
##                                           
##  Mcnemar's Test P-Value : 2.092e-05       
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.5606   0.6800  1.00000
## Recall                 0.9024   0.5312  0.10000
## F1                     0.6916   0.5965  0.18182
## Prevalence             0.4409   0.3441  0.21505
## Detection Rate         0.3978   0.1828  0.02151
## Detection Prevalence   0.7097   0.2688  0.02151
## Balanced Accuracy      0.6724   0.7001  0.55000
#test set predictions
pred_test <-predict(svm_model_cs_tuned,test_set)
mean(pred_test==test_set$SPSPtCtrl)
## [1] 0.5853659
confusionMatrix(pred_test,test_set$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 17  7  6
##          1  1  7  3
##          2  0  0  0
## 
## Overall Statistics
##                                           
##                Accuracy : 0.5854          
##                  95% CI : (0.4211, 0.7368)
##     No Information Rate : 0.439           
##     P-Value [Acc > NIR] : 0.042254        
##                                           
##                   Kappa : 0.2938          
##                                           
##  Mcnemar's Test P-Value : 0.003671        
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.5667   0.6364       NA
## Recall                 0.9444   0.5000   0.0000
## F1                     0.7083   0.5600       NA
## Prevalence             0.4390   0.3415   0.2195
## Detection Rate         0.4146   0.1707   0.0000
## Detection Prevalence   0.7317   0.2683   0.0000
## Balanced Accuracy      0.6896   0.6759   0.5000

K Nearest Neighbors

set.seed(321) 
split = sample.split(temat.cog.fs.flux.2.imputed$SPSPtCtrl, SplitRatio = 0.70) 

training_set = subset(temat.cog.fs.flux.2.imputed, split == TRUE) 
test_set = subset(temat.cog.fs.flux.2.imputed, split == FALSE) 

training_set$SPSPtCtrl <- as.factor(training_set$SPSPtCtrl)
test_set$SPSPtCtrl <- as.factor(test_set$SPSPtCtrl)

#feature scaling 
training_set[-22] = scale(training_set[-22]) 
test_set[-22] = scale(test_set[-22]) 

#Model tutning
set.seed(321)
ctrl <- trainControl(method="cv",number = 3, savePredictions = T) #,classProbs=TRUE,summaryFunction = twoClassSummary)
knnFit <- train(SPSPtCtrl ~ ., data = training_set, method = "knn", trControl = ctrl, tuneLength = 3) # optimal k = 5
knnFit
## k-Nearest Neighbors 
## 
## 93 samples
## 21 predictors
##  3 classes: '0', '1', '2' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 63, 61, 62 
## Resampling results across tuning parameters:
## 
##   k  Accuracy   Kappa      
##   5  0.3012545  -0.11037267
##   7  0.3439740  -0.05187739
##   9  0.4102599   0.04130145
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was k = 9.
#training set predictions
pred_train_knn <-predict(knnFit,training_set)
mean(pred_train_knn==training_set$SPSPtCtrl)
## [1] 0.5268817
confusionMatrix(pred_train_knn,training_set$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 33 14 13
##          1  6 15  6
##          2  2  3  1
## 
## Overall Statistics
##                                           
##                Accuracy : 0.5269          
##                  95% CI : (0.4206, 0.6314)
##     No Information Rate : 0.4409          
##     P-Value [Acc > NIR] : 0.059082        
##                                           
##                   Kappa : 0.2138          
##                                           
##  Mcnemar's Test P-Value : 0.006523        
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.5500   0.5556  0.16667
## Recall                 0.8049   0.4688  0.05000
## F1                     0.6535   0.5085  0.07692
## Prevalence             0.4409   0.3441  0.21505
## Detection Rate         0.3548   0.1613  0.01075
## Detection Prevalence   0.6452   0.2903  0.06452
## Balanced Accuracy      0.6428   0.6360  0.49075
#test set predictions
pred_test_knn <-predict(knnFit,test_set)
mean(pred_test_knn==test_set$SPSPtCtrl)
## [1] 0.5609756
confusionMatrix(pred_test_knn,test_set$SPSPtCtrl, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1  2
##          0 14  5  4
##          1  2  8  4
##          2  2  1  1
## 
## Overall Statistics
##                                           
##                Accuracy : 0.561           
##                  95% CI : (0.3975, 0.7153)
##     No Information Rate : 0.439           
##     P-Value [Acc > NIR] : 0.07888         
##                                           
##                   Kappa : 0.287           
##                                           
##  Mcnemar's Test P-Value : 0.28947         
## 
## Statistics by Class:
## 
##                      Class: 0 Class: 1 Class: 2
## Precision              0.6087   0.5714  0.25000
## Recall                 0.7778   0.5714  0.11111
## F1                     0.6829   0.5714  0.15385
## Prevalence             0.4390   0.3415  0.21951
## Detection Rate         0.3415   0.1951  0.02439
## Detection Prevalence   0.5610   0.3415  0.09756
## Balanced Accuracy      0.6932   0.6746  0.50868

Exploratory Analyses: Distinguishing OCD patients vs. healthy controls

Random Forest

set.seed(321)
split = sample.split(temat.cog.fs.flux.2.imputed$Pt, SplitRatio = 0.70) 

TrainSet = subset(temat.cog.fs.flux.2.imputed, split == TRUE) 
ValidSet = subset(temat.cog.fs.flux.2.imputed, split == FALSE) 

TrainSet$Pt <- as.factor(as.character(TrainSet$Pt))
ValidSet$Pt <- as.factor(as.character(ValidSet$Pt))

#verify the distribution of 0s/1s in the training/validation sets
prop.table(table(TrainSet$Pt)) * 100
## 
##        0        1 
## 39.42308 60.57692
prop.table(table(ValidSet$Pt)) * 100
## 
##  0  1 
## 40 60
# 3-fold CV with caret
control <- trainControl(method="cv", number=3, search="random", savePredictions = "final")

# Tune to determine optimal ntree
set.seed(321)
tunegrid <- expand.grid(.mtry=c(sqrt(ncol(TrainSet))))
modellist <- list()
for (ntree in c(51,101,501,601,701,801,901,1001)) {
    set.seed(321)
    fit <- train(Pt~., data=TrainSet, method="rf", tuneGrid=tunegrid, trControl=control, ntree=ntree)
    key <- toString(ntree)
    modellist[[key]] <- fit
}
modellist # highest accuracy: 801 trees
## $`51`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6635854  0.2872582
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`101`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6439776  0.2409437
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`501`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6633053  0.2821841
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`601`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6823529  0.3195772
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`701`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6823529  0.3195772
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`801`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa   
##   0.6728291  0.300644
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`901`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa   
##   0.6728291  0.300644
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1001`
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results:
## 
##   Accuracy   Kappa   
##   0.6728291  0.300644
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
# figure out optimal mtry
set.seed(321)
rf_random <- train(Pt~., data=TrainSet, method="rf", trControl=control, tuneLength=16, ntree=801)

#accuracy in training set
print(rf_random)
## Random Forest 
## 
## 104 samples
##  21 predictor
##   2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 70, 69, 69 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##    2    0.6535014  0.2528904
##    4    0.6630252  0.2766922
##    9    0.6630252  0.2813805
##   11    0.6728291  0.3006440
##   13    0.6725490  0.3016471
##   14    0.6630252  0.2808033
##   15    0.7014006  0.3603278
##   16    0.6434174  0.2443913
##   17    0.6535014  0.2656974
##   18    0.6630252  0.2831871
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 15.
confusionMatrix(rf_random$pred[order(rf_random$pred$rowIndex),2], TrainSet$Pt)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 22 12
##          1 19 51
##                                           
##                Accuracy : 0.7019          
##                  95% CI : (0.6043, 0.7877)
##     No Information Rate : 0.6058          
##     P-Value [Acc > NIR] : 0.02679         
##                                           
##                   Kappa : 0.3567          
##                                           
##  Mcnemar's Test P-Value : 0.28120         
##                                           
##             Sensitivity : 0.5366          
##             Specificity : 0.8095          
##          Pos Pred Value : 0.6471          
##          Neg Pred Value : 0.7286          
##              Prevalence : 0.3942          
##          Detection Rate : 0.2115          
##    Detection Prevalence : 0.3269          
##       Balanced Accuracy : 0.6731          
##                                           
##        'Positive' Class : 0               
## 
confusionMatrix(rf_random$pred[order(rf_random$pred$rowIndex),2], TrainSet$Pt, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 22 12
##          1 19 51
##                                           
##                Accuracy : 0.7019          
##                  95% CI : (0.6043, 0.7877)
##     No Information Rate : 0.6058          
##     P-Value [Acc > NIR] : 0.02679         
##                                           
##                   Kappa : 0.3567          
##                                           
##  Mcnemar's Test P-Value : 0.28120         
##                                           
##               Precision : 0.6471          
##                  Recall : 0.5366          
##                      F1 : 0.5867          
##              Prevalence : 0.3942          
##          Detection Rate : 0.2115          
##    Detection Prevalence : 0.3269          
##       Balanced Accuracy : 0.6731          
##                                           
##        'Positive' Class : 0               
## 
#accuracy in test set
pred_1 = predict(rf_random, ValidSet, type="raw")
confusionMatrix(pred_1, ValidSet$Pt, mode="prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0  8  6
##          1 10 21
##                                           
##                Accuracy : 0.6444          
##                  95% CI : (0.4878, 0.7813)
##     No Information Rate : 0.6             
##     P-Value [Acc > NIR] : 0.3272          
##                                           
##                   Kappa : 0.2308          
##                                           
##  Mcnemar's Test P-Value : 0.4533          
##                                           
##               Precision : 0.5714          
##                  Recall : 0.4444          
##                      F1 : 0.5000          
##              Prevalence : 0.4000          
##          Detection Rate : 0.1778          
##    Detection Prevalence : 0.3111          
##       Balanced Accuracy : 0.6111          
##                                           
##        'Positive' Class : 0               
## 
#variable importance
vi.rf.temat <- varImp(rf_random, scale=T, useModel = T)
plot(vi.rf.temat)

Support Vector Machine

#splitting the data set into the Training set and Test set 
set.seed(321) 
split = sample.split(temat.cog.fs.flux.2.imputed$Pt, SplitRatio = 0.70) 

training_set = subset(temat.cog.fs.flux.2.imputed, split == TRUE) 
test_set = subset(temat.cog.fs.flux.2.imputed, split == FALSE) 

training_set$Pt <- as.factor(training_set$Pt)
test_set$Pt <- as.factor(test_set$Pt)

#feature scaling 
training_set[-22] = scale(training_set[-22]) 
test_set[-22] = scale(test_set[-22]) 

prop.table(table(training_set$Pt)) * 100
## 
##        0        1 
## 39.42308 60.57692
prop.table(table(test_set$Pt)) * 100
## 
##  0  1 
## 40 60
#find optimal tuning parameters for svm assuming radial kernel
trainacc = c() # empty vector to store accuracy for training set
testacc = c() # empty vector to store accuracy for test set

#caret is limited to tuning one kernel at a time--we manually loop through
kernel_list <- list("linear", "polynomial", "radial", "sigmoid")
cost_list <- list(.5,1,1.25,1.4,1.5,1.75,2) # after zeroing in on optimal range
gamma_list <- list(0.125,0.25,0.5,1,2,4,8,16)


n <- 1
for (k in seq_along(kernel_list)){
  for (j in seq_along(cost_list)){
    for (i in seq_along(gamma_list)){
      set.seed(321)
      #run model with selected tuning parameters
      svm_model_cs_tuned <- svm(Pt~ ., data=training_set, method="C-classification", kernel=kernel_list[[k]],cost=cost_list[[j]],gamma=gamma_list[[i]])
      #training set predictions
      pred_train <-predict(svm_model_cs_tuned,training_set)
      mean(pred_train==training_set$Pt)
      trainacc[n] <- mean(pred_train==training_set$Pt)
      #test set predictions
      pred_test <-predict(svm_model_cs_tuned,test_set)
      testacc[n] <- mean(pred_test==test_set$Pt)
      
      n <- n+1
    }
  }
}

#examine train and test accuracy side by side
kernels <- c(rep("linear",56),rep("polynomial",56),rep("radial",56),rep("sigmoid",56))
costprep <- c(rep(".5",8), rep("1",8),rep("1.25",8),rep("1.4",8),rep("1.5",8),rep("1.75",8),rep("2",8))
costs <- rep(costprep,4)
gammasprep <- c(0.125,0.25,0.5,1,2,4,8,16)
gammas <- c(rep(gammasprep, 28))
accuracytable <- cbind(trainacc, testacc, kernels, gammas, costs)
#accuracytable

# run model using best cost, gamma, kernel and cross-validation
set.seed(321)
svm_model_cs_tuned <- svm(Pt~ ., data=training_set, method="C-classification", kernel="linear",cost=1.5, cross=3)

#training set predictions
pred_train <-predict(svm_model_cs_tuned,training_set)
mean(pred_train==training_set$Pt)
## [1] 0.7403846
confusionMatrix(pred_train,training_set$Pt, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 23  9
##          1 18 54
##                                           
##                Accuracy : 0.7404          
##                  95% CI : (0.6452, 0.8214)
##     No Information Rate : 0.6058          
##     P-Value [Acc > NIR] : 0.002783        
##                                           
##                   Kappa : 0.4348          
##                                           
##  Mcnemar's Test P-Value : 0.123658        
##                                           
##               Precision : 0.7188          
##                  Recall : 0.5610          
##                      F1 : 0.6301          
##              Prevalence : 0.3942          
##          Detection Rate : 0.2212          
##    Detection Prevalence : 0.3077          
##       Balanced Accuracy : 0.7091          
##                                           
##        'Positive' Class : 0               
## 
#test set predictions
pred_test <-predict(svm_model_cs_tuned,test_set)
mean(pred_test==test_set$Pt)
## [1] 0.6
confusionMatrix(pred_test,test_set$Pt, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0  6  6
##          1 12 21
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.4433, 0.743)
##     No Information Rate : 0.6            
##     P-Value [Acc > NIR] : 0.5643         
##                                          
##                   Kappa : 0.1176         
##                                          
##  Mcnemar's Test P-Value : 0.2386         
##                                          
##               Precision : 0.5000         
##                  Recall : 0.3333         
##                      F1 : 0.4000         
##              Prevalence : 0.4000         
##          Detection Rate : 0.1333         
##    Detection Prevalence : 0.2667         
##       Balanced Accuracy : 0.5556         
##                                          
##        'Positive' Class : 0              
## 

K Nearest Neighbors

#model tuning
set.seed(321)
ctrl <- trainControl(method="cv",number = 3)
knnFit <- train(Pt ~ ., data = training_set, method = "knn", trControl = ctrl, tuneLength = 2) #optimal k is 5

#training set predictions
pred_train_knn <-predict(knnFit,training_set)
mean(pred_train_knn==training_set$Pt)
## [1] 0.7692308
confusionMatrix(pred_train_knn,training_set$Pt, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 29 12
##          1 12 51
##                                           
##                Accuracy : 0.7692          
##                  95% CI : (0.6764, 0.8462)
##     No Information Rate : 0.6058          
##     P-Value [Acc > NIR] : 0.0003148       
##                                           
##                   Kappa : 0.5168          
##                                           
##  Mcnemar's Test P-Value : 1.0000000       
##                                           
##               Precision : 0.7073          
##                  Recall : 0.7073          
##                      F1 : 0.7073          
##              Prevalence : 0.3942          
##          Detection Rate : 0.2788          
##    Detection Prevalence : 0.3942          
##       Balanced Accuracy : 0.7584          
##                                           
##        'Positive' Class : 0               
## 
#test set predictions
pred_test_knn <-predict(knnFit,test_set)
mean(pred_test_knn==test_set$Pt)
## [1] 0.6
confusionMatrix(pred_test_knn,test_set$Pt, mode = "prec_recall")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0  8  8
##          1 10 19
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.4433, 0.743)
##     No Information Rate : 0.6            
##     P-Value [Acc > NIR] : 0.5643         
##                                          
##                   Kappa : 0.1509         
##                                          
##  Mcnemar's Test P-Value : 0.8137         
##                                          
##               Precision : 0.5000         
##                  Recall : 0.4444         
##                      F1 : 0.4706         
##              Prevalence : 0.4000         
##          Detection Rate : 0.1778         
##    Detection Prevalence : 0.3556         
##       Balanced Accuracy : 0.5741         
##                                          
##        'Positive' Class : 0              
##