Distinguishing OCD patients vs. healthy controls

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() 

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")

# 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, tunelength=16, ntree=ntree)
    key <- toString(ntree)
    modellist[[key]] <- fit
}
modellist # highest accuracy: 701 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(5)
rf_random <- train(Pt~., data=TrainSet, method="rf", tuneLength=7, trControl=control, ntree=701)

#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: 69, 70, 69 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##    3    0.6061625  0.1260846
##    7    0.6061625  0.1496509
##    9    0.6064426  0.1513282
##   11    0.6263305  0.1960337
##   15    0.6257703  0.1999161
##   19    0.6352941  0.2164774
##   21    0.6252101  0.1826977
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 19.
confusionMatrix(rf_random$finalModel$predicted, TrainSet$Pt)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 21 14
##          1 20 49
##                                           
##                Accuracy : 0.6731          
##                  95% CI : (0.5741, 0.7619)
##     No Information Rate : 0.6058          
##     P-Value [Acc > NIR] : 0.09506         
##                                           
##                   Kappa : 0.2976          
##                                           
##  Mcnemar's Test P-Value : 0.39117         
##                                           
##             Sensitivity : 0.5122          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.7101          
##              Prevalence : 0.3942          
##          Detection Rate : 0.2019          
##    Detection Prevalence : 0.3365          
##       Balanced Accuracy : 0.6450          
##                                           
##        'Positive' Class : 0               
## 
#accuracy in test set
pred_1 = predict(rf_random, ValidSet, type="raw")
confusionMatrix(pred_1, ValidSet$Pt)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0  9  6
##          1  9 21
##                                        
##                Accuracy : 0.6667       
##                  95% CI : (0.5105, 0.8)
##     No Information Rate : 0.6          
##     P-Value [Acc > NIR] : 0.2249       
##                                        
##                   Kappa : 0.2857       
##                                        
##  Mcnemar's Test P-Value : 0.6056       
##                                        
##             Sensitivity : 0.5000       
##             Specificity : 0.7778       
##          Pos Pred Value : 0.6000       
##          Neg Pred Value : 0.7000       
##              Prevalence : 0.4000       
##          Detection Rate : 0.2000       
##    Detection Prevalence : 0.3333       
##       Balanced Accuracy : 0.6389       
##                                        
##        'Positive' Class : 0            
## 
#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$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(2)
      #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(2)
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)
## 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        
##                                           
##             Sensitivity : 0.5610          
##             Specificity : 0.8571          
##          Pos Pred Value : 0.7187          
##          Neg Pred Value : 0.7500          
##              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)
## 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         
##                                          
##             Sensitivity : 0.3333         
##             Specificity : 0.7778         
##          Pos Pred Value : 0.5000         
##          Neg Pred Value : 0.6364         
##              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)
## 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       
##                                           
##             Sensitivity : 0.7073          
##             Specificity : 0.8095          
##          Pos Pred Value : 0.7073          
##          Neg Pred Value : 0.8095          
##              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)
## 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         
##                                          
##             Sensitivity : 0.4444         
##             Specificity : 0.7037         
##          Pos Pred Value : 0.5000         
##          Neg Pred Value : 0.6552         
##              Prevalence : 0.4000         
##          Detection Rate : 0.1778         
##    Detection Prevalence : 0.3556         
##       Balanced Accuracy : 0.5741         
##                                          
##        'Positive' Class : 0              
## 

Testing predictability of OCD patients with and without sensory phenomena

Random Forest

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

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

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

#verify the distribution of 0s/1s in the training/validation sets
prop.table(table(TrainSet$SPSyn)) * 100
## 
##        0        1 
## 61.53846 38.46154
prop.table(table(ValidSet$SPSyn)) * 100
## 
##        0        1 
## 60.86957 39.13043
# 3-fold CV with caret
control <- trainControl(method="cv", number=3, search="random")

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

for (ntree in c(51,101,501,601,701,801,901,1001,1101)) {
    set.seed(123)
    fit <- train(SPSyn~., data=TrainSet, method="rf", tuneGrid=tunegrid, trControl=control, tunelength=8, ntree=ntree)
    key <- toString(ntree)
    modellist[[key]] <- fit
}
modellist # highest accuracy: 601 trees
## $`51`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.5648148  0.02497972
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`101`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa       
##   0.5462963  -0.005697499
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`501`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6018519  0.1029018
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`601`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6018519  0.1029018
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`701`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa     
##   0.5810185  0.04136333
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`801`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6018519  0.1029018
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`901`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6018519  0.1029018
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1001`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6018519  0.1029018
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
## 
## $`1101`
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.5833333  0.0545901
## 
## Tuning parameter 'mtry' was held constant at a value of 4.690416
set.seed(123)
rf_random <- train(SPSyn~., data=TrainSet, method="rf", tuneLength=8, trControl=control, ntree=601)
print(rf_random)
## Random Forest 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 36, 34 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa       
##    3    0.5625000  -0.006948357
##    5    0.5810185   0.044566210
##   10    0.6203704   0.154416360
##   11    0.6018519   0.123183483
##   14    0.6018519   0.123183483
##   18    0.6203704   0.154871795
##   19    0.6203704   0.171495171
##   20    0.6018519   0.103912891
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 10.
confusionMatrix(rf_random$finalModel$predicted, TrainSet$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 23 17
##          1  9  3
##                                           
##                Accuracy : 0.5             
##                  95% CI : (0.3581, 0.6419)
##     No Information Rate : 0.6154          
##     P-Value [Acc > NIR] : 0.9667          
##                                           
##                   Kappa : -0.1419         
##                                           
##  Mcnemar's Test P-Value : 0.1698          
##                                           
##             Sensitivity : 0.7188          
##             Specificity : 0.1500          
##          Pos Pred Value : 0.5750          
##          Neg Pred Value : 0.2500          
##              Prevalence : 0.6154          
##          Detection Rate : 0.4423          
##    Detection Prevalence : 0.7692          
##       Balanced Accuracy : 0.4344          
##                                           
##        'Positive' Class : 0               
## 
pred_1 = predict(rf_random, ValidSet, type="raw")
confusionMatrix(pred_1, ValidSet$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 11  8
##          1  3  1
##                                           
##                Accuracy : 0.5217          
##                  95% CI : (0.3059, 0.7318)
##     No Information Rate : 0.6087          
##     P-Value [Acc > NIR] : 0.8570          
##                                           
##                   Kappa : -0.1145         
##                                           
##  Mcnemar's Test P-Value : 0.2278          
##                                           
##             Sensitivity : 0.7857          
##             Specificity : 0.1111          
##          Pos Pred Value : 0.5789          
##          Neg Pred Value : 0.2500          
##              Prevalence : 0.6087          
##          Detection Rate : 0.4783          
##    Detection Prevalence : 0.8261          
##       Balanced Accuracy : 0.4484          
##                                           
##        'Positive' Class : 0               
## 

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$SPSyn, 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$SPSyn <- as.factor(training_set$SPSyn)
test_set$SPSyn <- as.factor(test_set$SPSyn)

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

prop.table(table(training_set$SPSyn)) * 100
## 
##        0        1 
## 61.53846 38.46154
prop.table(table(test_set$SPSyn)) * 100
## 
##        0        1 
## 60.86957 39.13043
#find optimal tuning parameters for svm assuming radial kernel
#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(SPSyn~ ., 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$SPSyn)
      trainacc[n] <- mean(pred_train==training_set$SPSyn)
      #test set predictions
      pred_test <-predict(svm_model_cs_tuned,test_set)
      testacc[n] <- mean(pred_test==test_set$SPSyn)
      
      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.5",8),rep("2",8),rep("2.5",8),rep("3",8),rep("3.5",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.788461538461538" "0.347826086956522" "linear"     "0.125" ".5" 
##   [2,] "0.788461538461538" "0.347826086956522" "linear"     "0.25"  ".5" 
##   [3,] "0.788461538461538" "0.347826086956522" "linear"     "0.5"   ".5" 
##   [4,] "0.788461538461538" "0.347826086956522" "linear"     "1"     ".5" 
##   [5,] "0.788461538461538" "0.347826086956522" "linear"     "2"     ".5" 
##   [6,] "0.788461538461538" "0.347826086956522" "linear"     "4"     ".5" 
##   [7,] "0.788461538461538" "0.347826086956522" "linear"     "8"     ".5" 
##   [8,] "0.788461538461538" "0.347826086956522" "linear"     "16"    ".5" 
##   [9,] "0.846153846153846" "0.347826086956522" "linear"     "0.125" "1"  
##  [10,] "0.846153846153846" "0.347826086956522" "linear"     "0.25"  "1"  
##  [11,] "0.846153846153846" "0.347826086956522" "linear"     "0.5"   "1"  
##  [12,] "0.846153846153846" "0.347826086956522" "linear"     "1"     "1"  
##  [13,] "0.846153846153846" "0.347826086956522" "linear"     "2"     "1"  
##  [14,] "0.846153846153846" "0.347826086956522" "linear"     "4"     "1"  
##  [15,] "0.846153846153846" "0.347826086956522" "linear"     "8"     "1"  
##  [16,] "0.846153846153846" "0.347826086956522" "linear"     "16"    "1"  
##  [17,] "0.865384615384615" "0.304347826086957" "linear"     "0.125" "1.5"
##  [18,] "0.865384615384615" "0.304347826086957" "linear"     "0.25"  "1.5"
##  [19,] "0.865384615384615" "0.304347826086957" "linear"     "0.5"   "1.5"
##  [20,] "0.865384615384615" "0.304347826086957" "linear"     "1"     "1.5"
##  [21,] "0.865384615384615" "0.304347826086957" "linear"     "2"     "1.5"
##  [22,] "0.865384615384615" "0.304347826086957" "linear"     "4"     "1.5"
##  [23,] "0.865384615384615" "0.304347826086957" "linear"     "8"     "1.5"
##  [24,] "0.865384615384615" "0.304347826086957" "linear"     "16"    "1.5"
##  [25,] "0.865384615384615" "0.347826086956522" "linear"     "0.125" "2"  
##  [26,] "0.865384615384615" "0.347826086956522" "linear"     "0.25"  "2"  
##  [27,] "0.865384615384615" "0.347826086956522" "linear"     "0.5"   "2"  
##  [28,] "0.865384615384615" "0.347826086956522" "linear"     "1"     "2"  
##  [29,] "0.865384615384615" "0.347826086956522" "linear"     "2"     "2"  
##  [30,] "0.865384615384615" "0.347826086956522" "linear"     "4"     "2"  
##  [31,] "0.865384615384615" "0.347826086956522" "linear"     "8"     "2"  
##  [32,] "0.865384615384615" "0.347826086956522" "linear"     "16"    "2"  
##  [33,] "0.865384615384615" "0.347826086956522" "linear"     "0.125" "2.5"
##  [34,] "0.865384615384615" "0.347826086956522" "linear"     "0.25"  "2.5"
##  [35,] "0.865384615384615" "0.347826086956522" "linear"     "0.5"   "2.5"
##  [36,] "0.865384615384615" "0.347826086956522" "linear"     "1"     "2.5"
##  [37,] "0.865384615384615" "0.347826086956522" "linear"     "2"     "2.5"
##  [38,] "0.865384615384615" "0.347826086956522" "linear"     "4"     "2.5"
##  [39,] "0.865384615384615" "0.347826086956522" "linear"     "8"     "2.5"
##  [40,] "0.865384615384615" "0.347826086956522" "linear"     "16"    "2.5"
##  [41,] "0.865384615384615" "0.391304347826087" "linear"     "0.125" "3"  
##  [42,] "0.865384615384615" "0.391304347826087" "linear"     "0.25"  "3"  
##  [43,] "0.865384615384615" "0.391304347826087" "linear"     "0.5"   "3"  
##  [44,] "0.865384615384615" "0.391304347826087" "linear"     "1"     "3"  
##  [45,] "0.865384615384615" "0.391304347826087" "linear"     "2"     "3"  
##  [46,] "0.865384615384615" "0.391304347826087" "linear"     "4"     "3"  
##  [47,] "0.865384615384615" "0.391304347826087" "linear"     "8"     "3"  
##  [48,] "0.865384615384615" "0.391304347826087" "linear"     "16"    "3"  
##  [49,] "0.865384615384615" "0.391304347826087" "linear"     "0.125" "3.5"
##  [50,] "0.865384615384615" "0.391304347826087" "linear"     "0.25"  "3.5"
##  [51,] "0.865384615384615" "0.391304347826087" "linear"     "0.5"   "3.5"
##  [52,] "0.865384615384615" "0.391304347826087" "linear"     "1"     "3.5"
##  [53,] "0.865384615384615" "0.391304347826087" "linear"     "2"     "3.5"
##  [54,] "0.865384615384615" "0.391304347826087" "linear"     "4"     "3.5"
##  [55,] "0.865384615384615" "0.391304347826087" "linear"     "8"     "3.5"
##  [56,] "0.865384615384615" "0.391304347826087" "linear"     "16"    "3.5"
##  [57,] "0.980769230769231" "0.347826086956522" "polynomial" "0.125" ".5" 
##  [58,] "1"                 "0.434782608695652" "polynomial" "0.25"  ".5" 
##  [59,] "1"                 "0.434782608695652" "polynomial" "0.5"   ".5" 
##  [60,] "1"                 "0.434782608695652" "polynomial" "1"     ".5" 
##  [61,] "1"                 "0.434782608695652" "polynomial" "2"     ".5" 
##  [62,] "1"                 "0.434782608695652" "polynomial" "4"     ".5" 
##  [63,] "1"                 "0.434782608695652" "polynomial" "8"     ".5" 
##  [64,] "1"                 "0.434782608695652" "polynomial" "16"    ".5" 
##  [65,] "1"                 "0.434782608695652" "polynomial" "0.125" "1"  
##  [66,] "1"                 "0.434782608695652" "polynomial" "0.25"  "1"  
##  [67,] "1"                 "0.434782608695652" "polynomial" "0.5"   "1"  
##  [68,] "1"                 "0.434782608695652" "polynomial" "1"     "1"  
##  [69,] "1"                 "0.434782608695652" "polynomial" "2"     "1"  
##  [70,] "1"                 "0.434782608695652" "polynomial" "4"     "1"  
##  [71,] "1"                 "0.434782608695652" "polynomial" "8"     "1"  
##  [72,] "1"                 "0.434782608695652" "polynomial" "16"    "1"  
##  [73,] "1"                 "0.434782608695652" "polynomial" "0.125" "1.5"
##  [74,] "1"                 "0.434782608695652" "polynomial" "0.25"  "1.5"
##  [75,] "1"                 "0.434782608695652" "polynomial" "0.5"   "1.5"
##  [76,] "1"                 "0.434782608695652" "polynomial" "1"     "1.5"
##  [77,] "1"                 "0.434782608695652" "polynomial" "2"     "1.5"
##  [78,] "1"                 "0.434782608695652" "polynomial" "4"     "1.5"
##  [79,] "1"                 "0.434782608695652" "polynomial" "8"     "1.5"
##  [80,] "1"                 "0.434782608695652" "polynomial" "16"    "1.5"
##  [81,] "1"                 "0.434782608695652" "polynomial" "0.125" "2"  
##  [82,] "1"                 "0.434782608695652" "polynomial" "0.25"  "2"  
##  [83,] "1"                 "0.434782608695652" "polynomial" "0.5"   "2"  
##  [84,] "1"                 "0.434782608695652" "polynomial" "1"     "2"  
##  [85,] "1"                 "0.434782608695652" "polynomial" "2"     "2"  
##  [86,] "1"                 "0.434782608695652" "polynomial" "4"     "2"  
##  [87,] "1"                 "0.434782608695652" "polynomial" "8"     "2"  
##  [88,] "1"                 "0.434782608695652" "polynomial" "16"    "2"  
##  [89,] "1"                 "0.434782608695652" "polynomial" "0.125" "2.5"
##  [90,] "1"                 "0.434782608695652" "polynomial" "0.25"  "2.5"
##  [91,] "1"                 "0.434782608695652" "polynomial" "0.5"   "2.5"
##  [92,] "1"                 "0.434782608695652" "polynomial" "1"     "2.5"
##  [93,] "1"                 "0.434782608695652" "polynomial" "2"     "2.5"
##  [94,] "1"                 "0.434782608695652" "polynomial" "4"     "2.5"
##  [95,] "1"                 "0.434782608695652" "polynomial" "8"     "2.5"
##  [96,] "1"                 "0.434782608695652" "polynomial" "16"    "2.5"
##  [97,] "1"                 "0.434782608695652" "polynomial" "0.125" "3"  
##  [98,] "1"                 "0.434782608695652" "polynomial" "0.25"  "3"  
##  [99,] "1"                 "0.434782608695652" "polynomial" "0.5"   "3"  
## [100,] "1"                 "0.434782608695652" "polynomial" "1"     "3"  
## [101,] "1"                 "0.434782608695652" "polynomial" "2"     "3"  
## [102,] "1"                 "0.434782608695652" "polynomial" "4"     "3"  
## [103,] "1"                 "0.434782608695652" "polynomial" "8"     "3"  
## [104,] "1"                 "0.434782608695652" "polynomial" "16"    "3"  
## [105,] "1"                 "0.434782608695652" "polynomial" "0.125" "3.5"
## [106,] "1"                 "0.434782608695652" "polynomial" "0.25"  "3.5"
## [107,] "1"                 "0.434782608695652" "polynomial" "0.5"   "3.5"
## [108,] "1"                 "0.434782608695652" "polynomial" "1"     "3.5"
## [109,] "1"                 "0.434782608695652" "polynomial" "2"     "3.5"
## [110,] "1"                 "0.434782608695652" "polynomial" "4"     "3.5"
## [111,] "1"                 "0.434782608695652" "polynomial" "8"     "3.5"
## [112,] "1"                 "0.434782608695652" "polynomial" "16"    "3.5"
## [113,] "0.615384615384615" "0.608695652173913" "radial"     "0.125" ".5" 
## [114,] "0.615384615384615" "0.608695652173913" "radial"     "0.25"  ".5" 
## [115,] "0.615384615384615" "0.608695652173913" "radial"     "0.5"   ".5" 
## [116,] "0.615384615384615" "0.608695652173913" "radial"     "1"     ".5" 
## [117,] "0.615384615384615" "0.608695652173913" "radial"     "2"     ".5" 
## [118,] "0.615384615384615" "0.608695652173913" "radial"     "4"     ".5" 
## [119,] "0.615384615384615" "0.608695652173913" "radial"     "8"     ".5" 
## [120,] "0.615384615384615" "0.608695652173913" "radial"     "16"    ".5" 
## [121,] "0.923076923076923" "0.608695652173913" "radial"     "0.125" "1"  
## [122,] "1"                 "0.608695652173913" "radial"     "0.25"  "1"  
## [123,] "1"                 "0.608695652173913" "radial"     "0.5"   "1"  
## [124,] "1"                 "0.608695652173913" "radial"     "1"     "1"  
## [125,] "1"                 "0.608695652173913" "radial"     "2"     "1"  
## [126,] "1"                 "0.608695652173913" "radial"     "4"     "1"  
## [127,] "1"                 "0.608695652173913" "radial"     "8"     "1"  
## [128,] "1"                 "0.608695652173913" "radial"     "16"    "1"  
## [129,] "0.961538461538462" "0.565217391304348" "radial"     "0.125" "1.5"
## [130,] "1"                 "0.608695652173913" "radial"     "0.25"  "1.5"
## [131,] "1"                 "0.608695652173913" "radial"     "0.5"   "1.5"
## [132,] "1"                 "0.608695652173913" "radial"     "1"     "1.5"
## [133,] "1"                 "0.608695652173913" "radial"     "2"     "1.5"
## [134,] "1"                 "0.608695652173913" "radial"     "4"     "1.5"
## [135,] "1"                 "0.608695652173913" "radial"     "8"     "1.5"
## [136,] "1"                 "0.608695652173913" "radial"     "16"    "1.5"
## [137,] "1"                 "0.521739130434783" "radial"     "0.125" "2"  
## [138,] "1"                 "0.652173913043478" "radial"     "0.25"  "2"  
## [139,] "1"                 "0.608695652173913" "radial"     "0.5"   "2"  
## [140,] "1"                 "0.608695652173913" "radial"     "1"     "2"  
## [141,] "1"                 "0.608695652173913" "radial"     "2"     "2"  
## [142,] "1"                 "0.608695652173913" "radial"     "4"     "2"  
## [143,] "1"                 "0.608695652173913" "radial"     "8"     "2"  
## [144,] "1"                 "0.608695652173913" "radial"     "16"    "2"  
## [145,] "1"                 "0.565217391304348" "radial"     "0.125" "2.5"
## [146,] "1"                 "0.652173913043478" "radial"     "0.25"  "2.5"
## [147,] "1"                 "0.608695652173913" "radial"     "0.5"   "2.5"
## [148,] "1"                 "0.608695652173913" "radial"     "1"     "2.5"
## [149,] "1"                 "0.608695652173913" "radial"     "2"     "2.5"
## [150,] "1"                 "0.608695652173913" "radial"     "4"     "2.5"
## [151,] "1"                 "0.608695652173913" "radial"     "8"     "2.5"
## [152,] "1"                 "0.608695652173913" "radial"     "16"    "2.5"
## [153,] "1"                 "0.608695652173913" "radial"     "0.125" "3"  
## [154,] "1"                 "0.652173913043478" "radial"     "0.25"  "3"  
## [155,] "1"                 "0.608695652173913" "radial"     "0.5"   "3"  
## [156,] "1"                 "0.608695652173913" "radial"     "1"     "3"  
## [157,] "1"                 "0.608695652173913" "radial"     "2"     "3"  
## [158,] "1"                 "0.608695652173913" "radial"     "4"     "3"  
## [159,] "1"                 "0.608695652173913" "radial"     "8"     "3"  
## [160,] "1"                 "0.608695652173913" "radial"     "16"    "3"  
## [161,] "1"                 "0.608695652173913" "radial"     "0.125" "3.5"
## [162,] "1"                 "0.652173913043478" "radial"     "0.25"  "3.5"
## [163,] "1"                 "0.608695652173913" "radial"     "0.5"   "3.5"
## [164,] "1"                 "0.608695652173913" "radial"     "1"     "3.5"
## [165,] "1"                 "0.608695652173913" "radial"     "2"     "3.5"
## [166,] "1"                 "0.608695652173913" "radial"     "4"     "3.5"
## [167,] "1"                 "0.608695652173913" "radial"     "8"     "3.5"
## [168,] "1"                 "0.608695652173913" "radial"     "16"    "3.5"
## [169,] "0.615384615384615" "0.434782608695652" "sigmoid"    "0.125" ".5" 
## [170,] "0.519230769230769" "0.521739130434783" "sigmoid"    "0.25"  ".5" 
## [171,] "0.519230769230769" "0.521739130434783" "sigmoid"    "0.5"   ".5" 
## [172,] "0.461538461538462" "0.434782608695652" "sigmoid"    "1"     ".5" 
## [173,] "0.442307692307692" "0.434782608695652" "sigmoid"    "2"     ".5" 
## [174,] "0.461538461538462" "0.521739130434783" "sigmoid"    "4"     ".5" 
## [175,] "0.442307692307692" "0.608695652173913" "sigmoid"    "8"     ".5" 
## [176,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    ".5" 
## [177,] "0.615384615384615" "0.521739130434783" "sigmoid"    "0.125" "1"  
## [178,] "0.5"               "0.521739130434783" "sigmoid"    "0.25"  "1"  
## [179,] "0.423076923076923" "0.565217391304348" "sigmoid"    "0.5"   "1"  
## [180,] "0.423076923076923" "0.565217391304348" "sigmoid"    "1"     "1"  
## [181,] "0.442307692307692" "0.652173913043478" "sigmoid"    "2"     "1"  
## [182,] "0.442307692307692" "0.521739130434783" "sigmoid"    "4"     "1"  
## [183,] "0.461538461538462" "0.521739130434783" "sigmoid"    "8"     "1"  
## [184,] "0.442307692307692" "0.521739130434783" "sigmoid"    "16"    "1"  
## [185,] "0.538461538461538" "0.478260869565217" "sigmoid"    "0.125" "1.5"
## [186,] "0.5"               "0.521739130434783" "sigmoid"    "0.25"  "1.5"
## [187,] "0.442307692307692" "0.565217391304348" "sigmoid"    "0.5"   "1.5"
## [188,] "0.423076923076923" "0.608695652173913" "sigmoid"    "1"     "1.5"
## [189,] "0.461538461538462" "0.565217391304348" "sigmoid"    "2"     "1.5"
## [190,] "0.5"               "0.565217391304348" "sigmoid"    "4"     "1.5"
## [191,] "0.5"               "0.652173913043478" "sigmoid"    "8"     "1.5"
## [192,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    "1.5"
## [193,] "0.5"               "0.478260869565217" "sigmoid"    "0.125" "2"  
## [194,] "0.461538461538462" "0.521739130434783" "sigmoid"    "0.25"  "2"  
## [195,] "0.442307692307692" "0.565217391304348" "sigmoid"    "0.5"   "2"  
## [196,] "0.5"               "0.478260869565217" "sigmoid"    "1"     "2"  
## [197,] "0.461538461538462" "0.565217391304348" "sigmoid"    "2"     "2"  
## [198,] "0.519230769230769" "0.565217391304348" "sigmoid"    "4"     "2"  
## [199,] "0.519230769230769" "0.652173913043478" "sigmoid"    "8"     "2"  
## [200,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    "2"  
## [201,] "0.519230769230769" "0.434782608695652" "sigmoid"    "0.125" "2.5"
## [202,] "0.461538461538462" "0.521739130434783" "sigmoid"    "0.25"  "2.5"
## [203,] "0.442307692307692" "0.565217391304348" "sigmoid"    "0.5"   "2.5"
## [204,] "0.461538461538462" "0.434782608695652" "sigmoid"    "1"     "2.5"
## [205,] "0.519230769230769" "0.608695652173913" "sigmoid"    "2"     "2.5"
## [206,] "0.519230769230769" "0.565217391304348" "sigmoid"    "4"     "2.5"
## [207,] "0.519230769230769" "0.652173913043478" "sigmoid"    "8"     "2.5"
## [208,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    "2.5"
## [209,] "0.5"               "0.434782608695652" "sigmoid"    "0.125" "3"  
## [210,] "0.461538461538462" "0.521739130434783" "sigmoid"    "0.25"  "3"  
## [211,] "0.442307692307692" "0.565217391304348" "sigmoid"    "0.5"   "3"  
## [212,] "0.442307692307692" "0.434782608695652" "sigmoid"    "1"     "3"  
## [213,] "0.538461538461538" "0.608695652173913" "sigmoid"    "2"     "3"  
## [214,] "0.519230769230769" "0.565217391304348" "sigmoid"    "4"     "3"  
## [215,] "0.557692307692308" "0.521739130434783" "sigmoid"    "8"     "3"  
## [216,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    "3"  
## [217,] "0.5"               "0.434782608695652" "sigmoid"    "0.125" "3.5"
## [218,] "0.461538461538462" "0.565217391304348" "sigmoid"    "0.25"  "3.5"
## [219,] "0.442307692307692" "0.565217391304348" "sigmoid"    "0.5"   "3.5"
## [220,] "0.442307692307692" "0.434782608695652" "sigmoid"    "1"     "3.5"
## [221,] "0.442307692307692" "0.565217391304348" "sigmoid"    "2"     "3.5"
## [222,] "0.519230769230769" "0.565217391304348" "sigmoid"    "4"     "3.5"
## [223,] "0.557692307692308" "0.521739130434783" "sigmoid"    "8"     "3.5"
## [224,] "0.442307692307692" "0.608695652173913" "sigmoid"    "16"    "3.5"
# run model using best cost, gamma, kernel and cross-validation
set.seed(321)
svm_model_cs_tuned <- svm(SPSyn~ ., data=training_set, method="C-classification", kernel="sigmoid",gamma=.125,cost=1, cross=3)

#training set predictions
pred_train <-predict(svm_model_cs_tuned,training_set)
mean(pred_train==training_set$SPSyn)
## [1] 0.6153846
confusionMatrix(pred_train,training_set$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 24 12
##          1  8  8
##                                          
##                Accuracy : 0.6154         
##                  95% CI : (0.4702, 0.747)
##     No Information Rate : 0.6154         
##     P-Value [Acc > NIR] : 0.5608         
##                                          
##                   Kappa : 0.1558         
##                                          
##  Mcnemar's Test P-Value : 0.5023         
##                                          
##             Sensitivity : 0.7500         
##             Specificity : 0.4000         
##          Pos Pred Value : 0.6667         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.6154         
##          Detection Rate : 0.4615         
##    Detection Prevalence : 0.6923         
##       Balanced Accuracy : 0.5750         
##                                          
##        'Positive' Class : 0              
## 
#test set predictions
pred_test <-predict(svm_model_cs_tuned,test_set)
mean(pred_test==test_set$SPSyn)
## [1] 0.5217391
confusionMatrix(pred_test,test_set$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction 0 1
##          0 9 6
##          1 5 3
##                                           
##                Accuracy : 0.5217          
##                  95% CI : (0.3059, 0.7318)
##     No Information Rate : 0.6087          
##     P-Value [Acc > NIR] : 0.857           
##                                           
##                   Kappa : -0.0243         
##                                           
##  Mcnemar's Test P-Value : 1.000           
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.3333          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.3750          
##              Prevalence : 0.6087          
##          Detection Rate : 0.3913          
##    Detection Prevalence : 0.6522          
##       Balanced Accuracy : 0.4881          
##                                           
##        'Positive' Class : 0               
## 

K Nearest Neighbors

set.seed(321) 
split = sample.split(temat.cog.fs.flux.2.imputed$SPSyn, 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$SPSyn <- as.factor(training_set$SPSyn)
test_set$SPSyn <- as.factor(test_set$SPSyn)

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

#Model tutning
set.seed(7)
ctrl <- trainControl(method="cv",number = 3) #,classProbs=TRUE,summaryFunction = twoClassSummary)
knnFit <- train(SPSyn ~ ., data = training_set, method = "knn", trControl = ctrl, tuneLength = 3) # optimal k = 5
knnFit
## k-Nearest Neighbors 
## 
## 52 samples
## 21 predictors
##  2 classes: '0', '1' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold) 
## Summary of sample sizes: 34, 35, 35 
## Resampling results across tuning parameters:
## 
##   k  Accuracy   Kappa      
##   5  0.5969499  -0.01449275
##   7  0.5784314  -0.02070494
##   9  0.5773420  -0.05187593
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was k = 5.
#training set predictions
pred_train_knn <-predict(knnFit,training_set)
mean(pred_train_knn==training_set$SPSyn)
## [1] 0.6730769
confusionMatrix(pred_train_knn,training_set$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 28 13
##          1  4  7
##                                           
##                Accuracy : 0.6731          
##                  95% CI : (0.5289, 0.7967)
##     No Information Rate : 0.6154          
##     P-Value [Acc > NIR] : 0.23993         
##                                           
##                   Kappa : 0.2457          
##                                           
##  Mcnemar's Test P-Value : 0.05235         
##                                           
##             Sensitivity : 0.8750          
##             Specificity : 0.3500          
##          Pos Pred Value : 0.6829          
##          Neg Pred Value : 0.6364          
##              Prevalence : 0.6154          
##          Detection Rate : 0.5385          
##    Detection Prevalence : 0.7885          
##       Balanced Accuracy : 0.6125          
##                                           
##        'Positive' Class : 0               
## 
#test set predictions
pred_test_knn <-predict(knnFit,test_set)
mean(pred_test_knn==test_set$SPSyn)
## [1] 0.5217391
confusionMatrix(pred_test_knn,test_set$SPSyn)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction  0  1
##          0 12  9
##          1  2  0
##                                           
##                Accuracy : 0.5217          
##                  95% CI : (0.3059, 0.7318)
##     No Information Rate : 0.6087          
##     P-Value [Acc > NIR] : 0.85697         
##                                           
##                   Kappa : -0.1659         
##                                           
##  Mcnemar's Test P-Value : 0.07044         
##                                           
##             Sensitivity : 0.8571          
##             Specificity : 0.0000          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.0000          
##              Prevalence : 0.6087          
##          Detection Rate : 0.5217          
##    Detection Prevalence : 0.9130          
##       Balanced Accuracy : 0.4286          
##                                           
##        'Positive' Class : 0               
##