# Pattern notebook

## TV 3

The sample size:

```(len (ssi sb (= \$tv 3)))
```
 15

How many subjects answered each quiz question correctly:

```(.sum (getl quiz (ssi sb (= \$tv 3))))
```
I value
better-amount 14
better-prob 15
immediate 11
faster-completion 15

The number of subjects who answered every question correctly:

```(setv s-tv3-all-correct (list
(. (ss (.all (getl quiz (ssi sb (= \$tv 3))) 1) \$) index)))
(len s-tv3-all-correct)
```
 10

Number of I choices, all TV 3 subjects (recall that there are 60 trials):

```(.sort-values (.sum :level "sn"
(= (getl ts (ssi sb (= \$tv 3)) "choice") "I")))
```
sn choice
s037 0
s038 0
s040 0
s041 0
s032 1
s035 2
s033 3
s036 3
s028 5
s026 11
s039 14
s031 20
s030 27
s029 30
s027 35

Number of I choices, only TV 3 subjects who answered every quiz question correctly:

```(.sort-values (.sum :level "sn"
(= (getl ts s-tv3-all-correct "choice") "I")))
```
sn choice
s037 0
s038 0
s040 0
s041 0
s032 1
s036 3
s028 5
s026 11
s031 20
s029 30

Quantiles of the above (expressed as proportions out of 60):

```(rd 2 (.quantile
(.mean (= (getl ts s-tv3-all-correct "choice") "I") :level "sn")
[.25 .5 .75]))
```
I choice
0.25 0.00
0.50 0.03
0.75 0.16

For comparison, the corresponding quantiles in the 49 subjects of Luhmann, Ishida, and Hajcak (2011) are .17, .43, and .63.

Also for comparison, here's the MTurk subjects:

```(.sort-values (.sum :level "sn"
(= (getl ts (ssi sb (< \$tv 3)) "choice") "I")))
```
sn choice
s022 0
s017 1
s019 1
s021 1
s023 3
s018 4
s016 6
s003 8
s006 14
s024 27

Choices of I after D has become available are still rare. This is the complete list:

```(ss
(getl ts (ssi sb (<= \$tv 3)))
(& (> \$rt \$dwait) (= \$choice "I")))
```
sn block trial dwait choice rt won tt
s024 3 1 11.568 I 13.188 4 6
s030 2 1 6.392 I 11.830 0 3
s030 3 3 7.716 I 9.756 0 8
s030 16 3 14.593 I 14.729 0 47
s039 9 2 6.995 I 8.186 4 25
s039 10 3 6.849 I 9.395 0 29

## TV 4

For TV 4, I changed the gamble amounts and probabilities and switched to hypothetical rewards. For TV 5, I reworded the first quiz question.

```(.sort-values (.sum :level "sn"
(= (getl ts (ssi sb (.isin \$tv [4 5])) "choice") "I")))
```
sn choice
s049 2
s046 17
s048 18
s047 32
s044 33
s045 33
s042 36
s043 42
```(rd 2 (.quantile
(.mean :level "sn"
(= (getl ts (ssi sb (.isin \$tv [4 5])) "choice") "I"))
[.25 .5 .75]))
```
I choice
0.25 0.30
0.50 0.54
0.75 0.56
```(learn-scatter (ssi sb (.isin \$tv [4 5])))
```

Here, black dots are I choices and white dots are D choices.

## TV 6

Same as TV 5, but with real rewards again.

```(.sort-values (.sum :level "sn"
(= (getl ts (ssi sb (= \$tv 6)) "choice") "I")))
```
sn choice
s054 1
s057 2
s055 8
s060 22
s050 24
s052 25
s059 27
s053 32
s058 36
s062 36
s051 39
```(rd 2 (.quantile
(.mean :level "sn"
(= (getl ts (ssi sb (= \$tv 6)) "choice") "I"))
[.25 .5 .75]))
```
I choice
0.25 0.25
0.50 0.42
0.75 0.57

Maybe a little less than TV 5, but not bad.

```(learn-scatter (ssi sb (= \$tv 6)))
```

## TV 7

Now we're randomly assigning all 4 conditions.

Choices of I after D has become available:

```(setv v (.sum :level "sn" (wc
(getl ts (ssi sb (.isin \$tv [7 8 9])))
(& (> \$rt \$dwait) (= \$choice "I")))))
(.sort-values :ascending F (get v (> v 0)))
```
sn value
s081 30
s095 14
s164 11
s160 8
s222 8
s245 7
s080 7
s147 6
s082 6
s123 5
s244 5
s237 4
s102 4
s214 4
s242 4
s161 4
s088 3
s234 3
s097 3
s143 2
s209 2
s182 2
s165 2
s066 2
s151 2
s127 2
s104 2
s134 2
s107 2
s216 1
s218 1
s220 1
s100 1
s230 1
s232 1
s207 1
s233 1
s093 1
s235 1
s083 1
s077 1
s243 1
s071 1
s105 1
s138 1
s200 1
s139 1
s190 1
s184 1
s181 1
s178 1
s114 1
s128 1
s130 1
s158 1
s152 1
s068 1
s133 1
s142 1
s140 1
s195 1

Let's exclude subjects who made 3 or more such errors.

```(setv s-late (. (get v (>= v 3)) index))
(setv s-good (sorted (- (set (ssi sb (.isin \$tv [7 8 9]))) (set s-late))))
(valcounts (getl sb s-good "cond"))
```
I cond
within_pattern 39
control 37
across_pattern 41
across_force_d 41

The number of subjects who got each possible number of quiz questions wrong:

```(valcounts (pd.Series (pd.Categorical
(\$ (ss sb (.isin \$tv [7 8 9])) quiz-qs-wrong)
:categories [0 1 2 3 4]
:ordered T)))
```
I value
0 94
1 48
2 29
3 3
4 3

And here's the number of subjects who got each quiz question wrong:

```(.sum (~ (getl quiz (ssi sb (.isin \$tv [7 8 9])))))
```
I value
better-amount 39
better-prob 15
immediate 33
faster-completion 40

Subjects per condition getting no quiz questions wrong and satisfying the above criteria:

```(valcounts (\$ (ss (getl sb s-good) (= \$quiz-qs-wrong 0)) cond))
```
I cond
within_pattern 20
control 21
across_pattern 23
across_force_d 21

### Plots

```(defmacro cond-trials [cond blocks trials]
`(getl ts
(ssi (getl sb s-good) (= \$cond ~cond))
~blocks
~trials))

(setv free-trials-tv7 (.sort-index (pd.concat [
(cond-trials "control" : :)
(cond-trials "within_pattern" : 1)
(cond-trials "across_pattern" (range 1 20 2) :)
(cond-trials "across_force_d" (range 1 20 2) :)])))
```

Here we have the proportion of I choices considering only free-choice trials, which are all 60 trials for control subjects, 30 trials for across-forced subjects, and 20 trials for within-forced subjects. Plots are per condition, with means marked by vertical lines.

```(i-prop-dotplot "control")
```
```(i-prop-dotplot "within_pattern")
```
```(i-prop-dotplot "across_pattern")
```
```(i-prop-dotplot "across_force_d")
```

#### Difference from first to last third

```(i-prop-dotplot "control" :diffs T)
```
```(i-prop-dotplot "within_pattern" :diffs T)
```
```(i-prop-dotplot "across_pattern" :diffs T)
```
```(i-prop-dotplot "across_force_d" :diffs T)
```

#### Last third only

```(i-prop-dotplot "control" :late-only T)
```
```(i-prop-dotplot "within_pattern" :late-only T)
```
```(i-prop-dotplot "across_pattern" :late-only T)
```
```(i-prop-dotplot "across_force_d" :late-only T)
```

## References

Luhmann, C. C., Ishida, K., & Hajcak, G. (2011). Intolerance of uncertainty and decisions about delayed, probabilistic rewards. Behavior Therapy, 42, 378–386. doi:10.1016/j.beth.2010.09.002. Retrieved from http://www.psychology.stonybrook.edu/cluhmann-/papers/luhmann-2011-bt.pdf