@decidables/discountable-elements 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,14 +33,140 @@ for use in HTML.
33
33
 
34
34
  Building blocks for interactive visualizations of HTD
35
35
 
36
- #### `CPTCalculation` / `<cpt-calculation>`
36
+ #### `DiscountableControl` / `<discountable-control>`
37
37
 
38
- Calculation and comparison of subjective utility for gamble and sure options
38
+ Control panel for HTD demos
39
39
 
40
- Displays a live comparison of the subjective utilities for gamble and sure options, indicating which
41
- one is better, or if they are equal. Breaks the calculation down into multiple steps. Leverages the
42
- concepts from live equations to explicitly link objective value/probability to subjective
43
- value/decision weight to subjective utility.
40
+ A configurable set of controls for user manipulation of examples of hyperbolic temporal discounting.
41
+ Controls can be provided for the number of trials, the timing of trials, and for running, pausing,
42
+ or resetting a block of trials.
43
+
44
+ ##### Attributes
45
+
46
+ - `trials: number = undefined`
47
+ - Show a slider for setting the number of trials, initialized to the value provided
48
+ - Options
49
+ - `1` to `100` in steps of `1`
50
+ - `duration: number = undefined`
51
+ - Show a slider for setting the duration of the stimulus, wait, and inter-trial interval on each
52
+ trial, initialized to the value provided in milliseconds
53
+ - Options
54
+ - `10` to `4000` in steps of `10`
55
+ - `run: boolean = false`
56
+ - Show a button to run the task
57
+ - `pause: boolean = false`
58
+ - Show a button to pause the task
59
+ - `reset: boolean = false`
60
+ - Show a button to reset the task
61
+
62
+ ##### Methods
63
+
64
+ - `complete()`
65
+ - Indicates that a trial block is done, so it can no longer be paused
66
+
67
+ ##### Custom Events
68
+
69
+ - `discountable-control-trials`
70
+ - Indicates the number of trials slider has been adjusted
71
+ - `detail`
72
+ - `trials: number`
73
+ - The new number of trials
74
+ - `discountable-control-duration`
75
+ - Indicates the duration of trials slider has been adjusted
76
+ - `detail`
77
+ - `duration: number`
78
+ - The new duration
79
+ - `discountable-control-run`
80
+ - Indicates the run button has been pushed
81
+ - `discountable-control-pause`
82
+ - Indicates the pause button has been pushed
83
+ - `discountable-control-reset`
84
+ - Indicates the reset button has been pushed
85
+
86
+ ##### Example
87
+
88
+ ```html
89
+ <discountable-control trials="15" duration="1500" run pause reset></discountable-control>
90
+ ```
91
+
92
+ #### `DiscountableResponse` / `<discountable-response>`
93
+
94
+ Response buttons and feedback for inter-temporal choice tasks
95
+
96
+ This element provides 'first' and 'second' response buttons. It can also display a running count
97
+ of the trials and display response feedback.
98
+
99
+ ##### Attributes
100
+
101
+ - `interactive: boolean = false`
102
+ - Allow user to respond, instead of just displaying simulated model responses
103
+ - `feedback: boolean = false`
104
+ - Display response feedback, i.e. 'First'
105
+ - `trial: boolean = false`
106
+ - Display the running count of trials, i.e. 'Trial: 2 of 10'
107
+
108
+ ##### Methods
109
+
110
+ - `start(as, ds, al, dl, trial)`
111
+ - Indicates that a trial has started, and its time to wait for a response
112
+ - Parameters
113
+ - `as: number`
114
+ - Amount of smaller sooner option
115
+ - `ds: number`
116
+ - Delay of smaller sooner option
117
+ - `al: number`
118
+ - Amount of larger later option
119
+ - `dl: number`
120
+ - Delay of larger later option
121
+ - `trial: number`
122
+ - The count of the trial within the block
123
+ - `stop()`
124
+ - Indicates that the trial is over and it is time to display any requested feedback
125
+ - **Note:** If no response has been made yet, the trial is recorded as having no response
126
+ - `first()`
127
+ - Emulate a 'first' response
128
+ - `second()`
129
+ - Emulate an 'second' response
130
+ - `responded(response)`
131
+ - Emulate a response
132
+ - Parameters
133
+ - `response: string`
134
+ - Whether to emulate a `'first'` or `'second'` response
135
+ - `reset()`
136
+ - Reset to the state at the start of a block of trials
137
+
138
+ ##### Custom Events
139
+
140
+ - `discountable-response`
141
+ - Indicates that a response has been made on this trial
142
+ - `detail`
143
+ - `trial: number`
144
+ - The count of this trial in the block
145
+ - `as: number`
146
+ - Amount of smaller sooner option
147
+ - `ds: number`
148
+ - Delay of smaller sooner option
149
+ - `al: number`
150
+ - Amount of larger later option
151
+ - `dl: number`
152
+ - Delay of larger later option
153
+ - `response: string`
154
+ - Whether the response was `'first'` or `'second'`
155
+
156
+ ##### Example
157
+
158
+ ```html
159
+ <discountable-response interactive feedback trial></discountable-response>
160
+ ```
161
+
162
+ #### `HTDCalculation` / `<htd-calculation>`
163
+
164
+ Calculation and comparison of subjective value for smaller sooner and larger later options
165
+
166
+ Displays a live comparison of the subjective values for smaller sooner and larger later options,
167
+ indicating which one is better, or if they are equal. Breaks the calculation down into multiple
168
+ steps. Leverages the concepts from live equations to explicitly link objective amount and delay to
169
+ subjective value.
44
170
 
45
171
  ##### Attributes
46
172
 
@@ -48,82 +174,67 @@ value/decision weight to subjective utility.
48
174
  - Show values instead of just the names of variables
49
175
  - `interactive: boolean = false`
50
176
  - Allow editing of numeric values
51
- - `win: number = 100`
52
- - Winning value in gamble
53
- - `loss: number = 0`
54
- - Losing value in gamble
55
- - `probability: number = 0.75`
56
- - Probability of *winning*
57
- - `sure: number = 50`
58
- - Sure value
59
- - `alpha: number = 0.8`
60
- - Parameter α (diminishing marginal utility)
61
- - `lambda: number = 1.2`
62
- - Parameter λ (loss aversion)
63
- - `gamma: number = 0.8`
64
- - Parameter γ (probability distortion)
177
+ - `amount-ss: number = 20`
178
+ - Amount of smaller sooner option
179
+ - `delay-ss: number = 5`
180
+ - Delay of smaller sooner option
181
+ - `amount-ll: number = 50`
182
+ - Amount of larger later option
183
+ - `delay-ll: number = 40`
184
+ - Delay of larger later option
185
+ - `k: number = 0.1`
186
+ - Parameter k (discounting factor)
65
187
 
66
188
  ##### Custom Events
67
189
 
68
- - `cpt-calculation-change`
190
+ - `htd-calculation-change`
69
191
  - Indicates that the values in the calculation have changed
70
192
  - `detail`
71
- - `xl: number`
72
- - New losing value for gamble
73
- - `xw: number`
74
- - New winning value for gamble
75
- - `pw: number`
76
- - New probability of winning gamble
77
- - `xs: number`
78
- - New sure value
79
- - `a: number`
80
- - New value for parameter α (diminishing marginal utility)
81
- - `l: number`
82
- - New value for parameter λ (loss aversion)
83
- - `g: number`
84
- - New value for parameter γ (probability distortion)
193
+ - `as: number`
194
+ - Amount of smaller sooner option
195
+ - `ds: number`
196
+ - Delay of smaller sooner option
197
+ - `al: number`
198
+ - Amount of larger later option
199
+ - `dl: number`
200
+ - Delay of larger later option
201
+ - `k: number`
202
+ - Parameter k (discounting factor)
85
203
 
86
204
  ##### Example
87
205
 
88
206
  ```html
89
- <cpt-calculation numeric interactive win="100" loss="0" probability="0.75" sure="50" alpha="0.8" lambda="1.2" gamma="0.8"></cpt-calculation>
207
+ <htd-calculation numeric interactive amount-ss="20" delay-ss="10" amount-ll="80" delay-ll="50" k="0.05"></htd-calculation>
90
208
  ```
91
209
 
92
- #### `CPTFit` / `<cpt-fit>`
210
+ #### `HTDFit` / `<htd-fit>`
93
211
 
94
- Fits CPT parameters to empirical data using a Bayesian model running in a WebWorker
212
+ Fits HTD parameters to empirical data using a Bayesian model running in a WebWorker
95
213
 
96
214
  The component displays trace plots of the sampling and histograms of the posterior distributions for
97
- the alpha, lambda, gamma, and luce parameters. The model consists of the following:
215
+ the k and luce parameters. The model consists of the following:
98
216
 
99
217
  - Parameters
100
- - **alpha**: beta prior with mean of 0.5 and sample size of 2.5
101
- - **lambda**: gamma prior with mean of 2.0 and shape of 3.0
102
- - **gamma**: beta prior with mean of 0.5 and sample size of 2.5
218
+ - **k**: gamma prior with mean of 2 and shape of 3
103
219
  - **luce**: gamma prior with mean of 2 and shape of 3
104
220
  - Data (for *i*th trial)
105
- - **xw_i**: gamble winning value
106
- - **xl_i**: gamble losing value
107
- - **pw_i**: gamble winning probability
108
- - **xs_i**: sure value
109
- - **response_i**: 'gamble' or 'sure'
221
+ - **as_i**: smaller sooner amount
222
+ - **ds_i**: smaller sooner delay
223
+ - **al_i**: larger later amount
224
+ - **dl_i**: larger later delay
225
+ - **response_i**: 'first' (smaller sooner) or 'second' (larger later)
110
226
  - Functions
111
227
  - **v()**: subjective value
112
- - v = if (x >= 0) x^a; if (x < 0) -l * (-x)^a
113
- - **w()**: decision weight
114
- - w = p^g / (p^g + (1 - p)^g)^(1 / g)
115
- - **u()**: utility
116
- - u = Sum_n(v_n * w_n)
228
+ - v = a / (1 + k * d)
117
229
  - **choice()**: Luce choice probability
118
- - cg = 1 / (1 + e^(luce * (us - ug)))
230
+ - cg = 1 / (1 + e^(luce * (vs - vl)))
119
231
  - Model
120
- - **ug_i**: subjective utility of the *i*th gamble
121
- - ug_i = u([v(xw_i, alpha, lambda), v(xl_i, alpha, lambda)],
122
- [w(pw_i, gamma), 1 - w(pw_i, gamma)])
123
- - **us_i**: subjective utility of the *i*th sure thing
124
- - us_i = v(xs_i, alpha, lambda)
125
- - **cg_i**: probability of choosing the *i*th gamble
126
- - cg_i = choice(us_i, ug_i, luce)
232
+ - **vs_i**: subjective value of the *i*th smaller sooner option
233
+ - vs_i = v(as_i, ds_i, k)
234
+ - **vl_i**: subjective value of the *i*th larger later option
235
+ - vl_i = v(al_i, dl_i, k)
236
+ - **cg_i**: probability of choosing the *i*th smaller sooner option
237
+ - cg_i = choice(vs_i, vl_i, luce)
127
238
  - **choice_i**: Bernoulli distribution given **response_i** and **cg_i**
128
239
 
129
240
  ##### Methods
@@ -139,33 +250,33 @@ the alpha, lambda, gamma, and luce parameters. The model consists of the followi
139
250
  - Identifier for the choice data
140
251
  - Return value
141
252
  - `choice: object` or `null`
142
- - `xl: number`
143
- - Gamble losing value
144
- - `xw: number`
145
- - Gamble winning value
146
- - `pw: number`
147
- - Gamble winning probability
148
- - `xs: number`
149
- - Sure value
253
+ - `as: number`
254
+ - Amount of smaller sooner option
255
+ - `ds: number`
256
+ - Delay of smaller sooner option
257
+ - `al: number`
258
+ - Amount of larger later option
259
+ - `dl: number`
260
+ - Delay of larger later option
150
261
  - `response: string`
151
- - Chosen option, either `'gamble'` or `'sure'`
262
+ - Chosen option, either `'first'` or `'second'`
152
263
  - `name: string`
153
264
  - Identifier for choice
154
265
  - `label: string`
155
266
  - Label for choice
156
- - `set(xl, xw, pw, xs, response, name = '', label = '')`
267
+ - `set(as, ds, al, dl, response, name = '', label = '')`
157
268
  - Creates or changes the specified choice data
158
269
  - Parameters
159
- - `xl: number`
160
- - Gamble losing value
161
- - `xw: number`
162
- - Gamble winning value
163
- - `pw: number`
164
- - Gamble winning probability
165
- - `xs: number`
166
- - Sure value
270
+ - `as: number`
271
+ - Amount of smaller sooner option
272
+ - `ds: number`
273
+ - Delay of smaller sooner option
274
+ - `al: number`
275
+ - Amount of larger later option
276
+ - `dl: number`
277
+ - Delay of larger later option
167
278
  - `response: string`
168
- - Chosen option, either `'gamble'` or `'sure'`
279
+ - Chosen option, either `'first'` or `'second'`
169
280
  - `name: string`
170
281
  - Identifier for choice
171
282
  - `label: string`
@@ -173,415 +284,138 @@ the alpha, lambda, gamma, and luce parameters. The model consists of the followi
173
284
 
174
285
  ##### Custom Events
175
286
 
176
- - `cpt-fit-update`
287
+ - `htd-fit-update`
177
288
  - Indicates that the fit has completed
178
289
  - `detail`
179
- - `a: number`
180
- - New value for parameter α (diminishing marginal utility)
181
- - `l: number`
182
- - New value for parameter λ (loss aversion)
183
- - `g: number`
184
- - New value for parameter γ (probability distortion)
185
-
186
- ##### Example
187
-
188
- ```html
189
- <cpt-fit></cpt-fit>
190
- ```
191
-
192
- #### `CPTProbability` / `<cpt-probability>`
193
-
194
- Decision weight function for CPT
195
-
196
- Maps from objective probability to subjective decision weight. Functions themselves and data points
197
- on the functions can be directly manipulated.
198
-
199
- ##### Attributes
200
-
201
- - `interactive: boolean = false`
202
- - Allow direct manipulation of functions or data points
203
- - `probability: number = null`
204
- - Probability
205
- - `gamma: number = 0.5`
206
- - Parameter γ (probability distortion)
207
- - `label: string = ''`
208
- - Label for data point
209
-
210
- ##### Methods
211
-
212
- - `trial(xl, xw, pw, xs, trial, response)`
213
- - Creates or changes the specified trial data
214
- - Parameters
215
- - `xl: number`
216
- - Gamble losing value
217
- - `xw: number`
218
- - Gamble winning value
219
- - `pw: number`
220
- - Gamble winning probability
221
- - `xs: number`
222
- - Sure value
223
- - `trial: number`
224
- - Trial count
225
- - `response: string`
226
- - Chosen option, either `'gamble'` or `'sure'`
227
- - `pauseTrial()`
228
- - Pause trial animations
229
- - `resumeTrial()`
230
- - Resume trial animations
231
- - `clearFunctions()`
232
- - Remove all functions except the default
233
- - `clearProbabilities()`
234
- - Remove all probabilities except the default
235
- - `clear()`
236
- - Remove all functions and probabilities except the defaults
237
- - `removeFunction(name)`
238
- - Remove the identified function
239
- - Parameters
240
- - `name: string`
241
- - Identifier for function
242
- - `removeProbability(name)`
243
- - Remove the identified probability
244
- - Parameters
245
- - `name: string`
246
- - Identifier for probability
247
- - `getFunction(name = 'default')`
248
- - Retrieve the identified function
249
- - Parameters
250
- - `name: string = 'default'`
251
- - Identifier for function
252
- - Return value
253
- - `function: object`
254
- - `name: string`
255
- - Identifier for function
256
- - `g: number`
257
- - Parameter γ (probability distortion)
258
- - `getProbability(name = 'default')`
259
- - Retrieve the identified probability
260
- - Parameters
261
- - `name: string = 'default'`
262
- - Identifier for probability
263
- - Return value
264
- - `probability: object`
265
- - `name: string`
266
- - Identifier for probability
267
- - `p: number`
268
- - Probability
269
- - `w: number`
270
- - Decision weight
271
- - `label: string`
272
- - Label
273
- - `function: string`
274
- - Name of function
275
- - `get(name = 'default')`
276
- - Retrieve the identified probability and function
277
- - Parameters
278
- - `name: string = 'default'`
279
- - Identifier for probability and function
280
- - Return value
281
- - `probability & function: object`
282
- - `name: string`
283
- - Identifier for probability and function
284
- - `p: number`
285
- - Probability
286
- - `g: number`
287
- - Parameter γ (probability distortion)
288
- - `w: number`
289
- - Decision weight
290
- - `label: string`
291
- - Label
292
- - `function: string`
293
- - Name of function
294
- - `setFunction(g, name = 'default')`
295
- - Create or change the identified function
296
- - Parameters
297
- - `g: number`
298
- - Parameter γ (probability distortion)
299
- - `name: string = 'default'`
300
- - Identifier for function
301
- - `setProbability(p, name = 'default', label = '', func = name, trial = false)`
302
- - Create or change the identified probability
303
- - Parameters
304
- - `p: number`
305
- - Probability
306
- - `name: string = 'default'`
307
- - Identifier for probability
308
- - `label: string = ''`
309
- - Label
310
- - `func: string = name`
311
- - Name of function
312
- - `trial: boolean = false`
313
- - Is this for an animated trial?
314
- - `set(p, g, name = 'default', label = '', func = name)`
315
- - Create or change the identified probability and function
316
- - Parameters
317
- - `p: number`
318
- - Probability
319
- - `g: number`
320
- - Parameter γ (probability distortion)
321
- - `name: string = 'default'`
322
- - Identifier for probability
323
- - `label: string = ''`
324
- - Label
325
- - `func: string = name`
326
- - Name of function
327
-
328
- ##### Custom Events
329
-
330
- - `cpt-probability-change`
331
- - Indicates that a function and/or probability has changed
332
- - `detail`
333
- - `name: string`
334
- - Identifier for probability
335
- - `p: number`
336
- - Probability
337
- - `g: number`
338
- - Parameter γ (probability distortion)
339
- - `w: number`
340
- - Decision weight
341
- - `label: string`
342
- - Label
343
- - `function: string`
344
- - Name of function
345
-
346
- ##### Example
347
-
348
- ```html
349
- <cpt-probability interactive probability="0.75" gamma="0.8"></cpt-probability>
350
- ```
351
-
352
- #### `CPTSpace` / `<cpt-space>`
353
-
354
- 3D representation of CPT parameter space for a given decision
355
-
356
- A 3D plot, with alpha, lambda, and gamma as the three dimensions. The current model parameters can
357
- be represented as a point in the space. A surface can be displayed representing the border between
358
- combinations of parameter values that will lead to a 'gamble' choice versus a 'sure' choice for the
359
- current decision.
360
-
361
- Note: This component relies on Plotly's 3d Isosurface and Scatter Plots, which seem to require a few
362
- megabytes of code, and are laggy to update, though direct interaction with the plot is snappy.
363
-
364
- ##### Attributes
365
-
366
- - `surface: boolean = true`
367
- - Should the surface separating 'gamble' choices versus 'sure' choices be displayed
368
- - `point: boolean = true`
369
- - Should the point representing the current parameter values be displayed
370
- - `updateable: boolean = false`
371
- - Can the color-coded response for the decision change based on current values
372
- - `alpha: number = 0.8`
373
- - Parameter α (diminishing marginal utility)
374
- - `lambda: number = 1.2`
375
- - Parameter λ (loss aversion)
376
- - `gamma: number = 0.8`
377
- - Parameter γ (probability distortion)
378
- - `win: number = 20`
379
- - Winning value in gamble
380
- - `loss: number = 0`
381
- - Losing value in gamble
382
- - `probability: number = 0.5`
383
- - Probability of *winning*
384
- - `sure: number = 10`
385
- - Sure value
290
+ - `k: number`
291
+ - New value for parameter k (discounting factor)
386
292
 
387
293
  ##### Example
388
294
 
389
295
  ```html
390
- <cpt-space updateable surface="true" point="true" alpha="0.75" lambda="1.2" gamma="0.8" win="20" loss="0" probability="0.5" sure="10"></cpt-space>
296
+ <htd-fit></htd-fit>
391
297
  ```
392
298
 
393
- #### `CPTValue` / `<cpt-value>`
299
+ #### `HTDCurves` / `<htd-curves>`
394
300
 
395
- Value function for CPT
301
+ Temporal discounting curves for HTD
396
302
 
397
- Maps from objective value to subjective value. Functions themselves and data points on the
398
- functions can be directly manipulated.
303
+ Displays options as an amount to be received at a certain delay, with a discounting curve
304
+ illustrating the present value of that option. The amount, the delay, and the discounting curve can
305
+ be directly manipulated.
399
306
 
400
307
  ##### Attributes
401
308
 
402
309
  - `interactive: boolean = false`
403
310
  - Allow direct manipulation of functions or data points
404
- - `value: number = null`
405
- - Objective value
406
- - `alpha: number = 0.5`
407
- - Parameter α (diminishing marginal utility)
408
- - `lambda: number = 2`
409
- - Parameter λ (loss aversion)
311
+ - `amount: number = null`
312
+ - Amount
313
+ - `delay: number = null`
314
+ - Delay
315
+ - `k: number = 0.1`
316
+ - Parameter k (discounting factor)
410
317
  - `label: string = ''`
411
318
  - Label for data point
412
319
 
413
320
  ##### Methods
414
321
 
415
- - `trial(xl, xw, pw, xs, trial, response)`
322
+ - `trial(as, ds, al, dl, trial, response)`
416
323
  - Creates or changes the specified trial data
417
324
  - Parameters
418
- - `xl: number`
419
- - Gamble losing value
420
- - `xw: number`
421
- - Gamble winning value
422
- - `pw: number`
423
- - Gamble winning probability
424
- - `xs: number`
425
- - Sure value
325
+ - `as: number`
326
+ - Amount of smaller sooner option
327
+ - `ds: number`
328
+ - Delay of smaller sooner option
329
+ - `al: number`
330
+ - Amount of larger later option
331
+ - `dl: number`
332
+ - Delay of larger later option
426
333
  - `trial: number`
427
334
  - Trial count
428
335
  - `response: string`
429
- - Chosen option, either `'gamble'` or `'sure'`
336
+ - Chosen option, either `'first'` or `'second'`
430
337
  - `pauseTrial()`
431
338
  - Pause trial animations
432
339
  - `resumeTrial()`
433
340
  - Resume trial animations
434
- - `clearFunctions()`
435
- - Remove all functions except the default
436
- - `clearValues()`
437
- - Remove all values except the default
438
- - `clear()`
439
- - Remove all functions and values except the defaults
440
- - `removeFunction(name)`
441
- - Remove the identified function
442
- - Parameters
443
- - `name: string`
444
- - Identifier for function
445
- - `removeValue(name)`
446
- - Remove the identified value
341
+ - `clearOptions()`
342
+ - Remove all options except the default
343
+ - `removeOption(name)`
344
+ - Remove the identified option
447
345
  - Parameters
448
346
  - `name: string`
449
- - Identifier for value
450
- - `getFunction(name = 'default')`
451
- - Retrieve the identified function
347
+ - Identifier for option
348
+ - `getOption(name = 'default')`
349
+ - Retrieve the identified option
452
350
  - Parameters
453
351
  - `name: string = 'default'`
454
- - Identifier for function
352
+ - Identifier for option
455
353
  - Return value
456
- - `function: object`
354
+ - `option: object`
457
355
  - `name: string`
458
- - Identifier for function
356
+ - Identifier for option
459
357
  - `a: number`
460
- - Parameter α (diminishing marginal utility)
461
- - `l: number`
462
- - Parameter λ (loss aversion)
463
- - `getValue(name = 'default')`
464
- - Retrieve the identified value
465
- - Parameters
466
- - `name: string = 'default'`
467
- - Identifier for value
468
- - Return value
469
- - `value: object`
470
- - `name: string`
471
- - Identifier for value
472
- - `x: number`
473
- - Objective value
474
- - `v: number`
475
- - Subjective value
358
+ - Amount of option
359
+ - `d: number`
360
+ - Delay of option
476
361
  - `label: string`
477
- - Label
478
- - `function: string`
479
- - Name of function
480
- - `get(name = 'default')`
481
- - Retrieve the identified value and function
482
- - Parameters
483
- - `name: string = 'default'`
484
- - Identifier for value and function
485
- - Return value
486
- - `value & function: object`
487
- - `name: string`
488
- - Identifier for value and function
489
- - `x: number`
490
- - Objective value
491
- - `a: number`
492
- - Parameter α (diminishing marginal utility)
493
- - `l: number`
494
- - Parameter λ (loss aversion)
495
- - `v: number`
496
- - Subjective value
497
- - `label: string`
498
- - Label
499
- - `function: string`
500
- - Name of function
501
- - `setFunction(a, l, name = 'default')`
502
- - Create or change the identified function
362
+ - Label for option
363
+ - `setOption(a, d, name = 'default', label = '', trial = false)`
364
+ - Create or change the identified option
503
365
  - Parameters
504
366
  - `a: number`
505
- - Parameter α (diminishing marginal utility)
506
- - `l: number`
507
- - Parameter λ (loss aversion)
508
- - `name: string = 'default'`
509
- - Identifier for function
510
- - `setValue(x, name = 'default', label = '', func = name, trial = false)`
511
- - Create or change the identified probability
512
- - Parameters
513
- - `x: number`
514
- - Objective value
367
+ - Amount of option
368
+ - `d: number`
369
+ - Delay of option
515
370
  - `name: string = 'default'`
516
- - Identifier for value
371
+ - Identifier for option
517
372
  - `label: string = ''`
518
- - Label
519
- - `func: string = name`
520
- - Name of function
373
+ - Label for option
521
374
  - `trial: boolean = false`
522
375
  - Is this for an animated trial?
523
- - `set(x, a, l, name = 'default', label = '', func = name)`
524
- - Create or change the identified value and function
525
- - Parameters
526
- - `x: number`
527
- - Objective value
528
- - `a: number`
529
- - Parameter α (diminishing marginal utility)
530
- - `l: number`
531
- - Parameter λ (loss aversion)
532
- - `name: string = 'default'`
533
- - Identifier for value
534
- - `label: string = ''`
535
- - Label
536
- - `func: string = name`
537
- - Name of function
538
376
 
539
377
  ##### Custom Events
540
378
 
541
- - `cpt-value-change`
542
- - Indicates that a function and/or value has changed
379
+ - `htd-curves-change`
380
+ - Indicates that an option has changed
543
381
  - `detail`
544
382
  - `name: string`
545
- - Identifier for value
546
- - `x: number`
547
- - Objective value
383
+ - Identifier for option
548
384
  - `a: number`
549
- - Parameter α (diminishing marginal utility)
550
- - `l: number`
551
- - Parameter λ (loss aversion)
552
- - `v: number`
553
- - Subjective value
385
+ - Amount
386
+ - `d: number`
387
+ - Delay
388
+ - `k: number`
389
+ - Parameter k (discounting factor)
554
390
  - `label: string`
555
- - Label
556
- - `function: string`
557
- - Name of function
391
+ - Label for option
558
392
 
559
393
  ##### Example
560
394
 
561
395
  ```html
562
- <cpt-value interactive value="20" alpha="0.8" lambda="1.2"></cpt-value>
396
+ <htd-curves interactive amount="60" delay="30" k="0.05" label="1"></htd-curves>
563
397
  ```
564
398
 
565
- #### `RiskyChoice` / `<risky-choice>`
399
+ #### `ITCChoice` / `<itc-choice>`
566
400
 
567
- A choice between two options, one a gamble, and one a sure thing
401
+ A choice between two options at different times
568
402
 
569
- Presents a choice between two options, a gamble and a sure thing. The display can either show the
570
- choice, a fixation, or a blank display. It is optionally interactive, in which case the values of
571
- the gamble win and the sure thing and the probability of the gamble win can be edited.
403
+ Presents a choice between two options, one smaller sooner and one larger later. The display can
404
+ either show the choice, a fixation, or a blank display. It is optionally interactive, in which case
405
+ the amounts and the delays can be edited.
572
406
 
573
407
  ##### Attributes
574
408
 
575
409
  - `interactive: boolean = false`
576
410
  - Allow direct manipulation of probabilities and values
577
- - `win: number = 20`
578
- - Winning value in gamble
579
- - `loss: number = 0`
580
- - Losing value in gamble
581
- - `probability: number = 0.5`
582
- - Probability of *winning*
583
- - `sure: number = 10`
584
- - Sure value
411
+ - `amount-ss: number = 20`
412
+ - Amount of smaller sooner option
413
+ - `delay-ss: number = 5`
414
+ - Delay of smaller sooner option
415
+ - `amount-ll: number = 50`
416
+ - Amount of larger later option
417
+ - `delay-ll: number = 40`
418
+ - Delay of larger later option
585
419
  - `state: string = 'choice'`
586
420
  - Current state of the display
587
421
  - Options
@@ -594,349 +428,74 @@ the gamble win and the sure thing and the probability of the gamble win can be e
594
428
 
595
429
  ##### Custom Events
596
430
 
597
- - `risky-choice-change`
431
+ - `itc-choice-change`
598
432
  - Indicates that one or more numbers in the choice have been changed
599
433
  - `detail`
600
- - `xl: number`
601
- - Objective value of gamble loss
602
- - `xw: number`
603
- - Objective value of gamble win
604
- - `pw: number`
605
- - Probability of gamble win
606
- - `xs: number`
607
- - Objective value of sure thing
434
+ - `as: number`
435
+ - Amount of smaller sooner option
436
+ - `ds: number`
437
+ - Delay of smaller sooner option
438
+ - `al: number`
439
+ - Amount of larger later option
440
+ - `dl: number`
441
+ - Delay of larger later option
608
442
 
609
443
  ##### Example
610
444
 
611
445
  ```html
612
- <risky-choice interactive probability="0.75" win="20" loss="0" sure="10" state="choice"></risky-choice>
446
+ <itc-choice interactive amount-ss="20" delay-ss="10" amount-ll="80" delay-ll="50" state="choice"></itc-choice>
613
447
  ```
614
448
 
615
- #### `ProspectableControl` / `<prospectable-control>`
449
+ #### `ITCOption` / `<itc-option>`
616
450
 
617
- Control panel for CPT demos
451
+ A single decision option consisting of an amount and a delay
618
452
 
619
- A configurable set of controls for user manipulation of examples of cumulative prospect theory.
620
- Controls can be provided for the number of trials, the timing of trials, and for running, pausing,
621
- or resetting a block of trials.
622
-
623
- ##### Attributes
624
-
625
- - `trials: number = undefined`
626
- - Show a slider for setting the number of trials, initialized to the value provided
627
- - Options
628
- - `1` to `100` in steps of `1`
629
- - `duration: number = undefined`
630
- - Show a slider for setting the duration of the stimulus, wait, and inter-trial interval on each
631
- trial, initialized to the value provided in milliseconds
632
- - Options
633
- - `10` to `4000` in steps of `10`
634
- - `run: boolean = false`
635
- - Show a button to run the task
636
- - `pause: boolean = false`
637
- - Show a button to pause the task
638
- - `reset: boolean = false`
639
- - Show a button to reset the task
640
-
641
- ##### Methods
642
-
643
- - `complete()`
644
- - Indicates that a trial block is done, so it can no longer be paused
645
-
646
- ##### Custom Events
647
-
648
- - `prospectable-control-trials`
649
- - Indicates the number of trials slider has been adjusted
650
- - `detail`
651
- - `trials: number`
652
- - The new number of trials
653
- - `prospectable-control-duration`
654
- - Indicates the duration of trials slider has been adjusted
655
- - `detail`
656
- - `duration: number`
657
- - The new duration
658
- - `prospectable-control-run`
659
- - Indicates the run button has been pushed
660
- - `prospectable-control-pause`
661
- - Indicates the pause button has been pushed
662
- - `prospectable-control-reset`
663
- - Indicates the reset button has been pushed
664
-
665
- ##### Example
666
-
667
- ```html
668
- <prospectable-control trials="15" duration="1500" run pause reset></prospectable-control>
669
- ```
670
-
671
- #### `RiskyOption` / `<risky-option>`
672
-
673
- A single decision option consisting of one or more decision outcomes
674
-
675
- Displays its possible outcomes as a pie chart, with the size representing the probability.
676
- Optionally, the size of the pie pieces can be directly manipulated and the values associated with
677
- them can be edited.
453
+ Displays its amount and delay numerically.
454
+ Optionally, the amount and the delay can be edited.
678
455
 
679
456
  ##### Attributes
680
457
 
681
458
  - `interactive: boolean = false`
682
459
  - Allow direct manipulation of probabilities and values
683
-
684
- ##### Slots
685
-
686
- - *unnamed*
687
- - Place the constituent decision outcomes here
688
- - `<risky-outcome>`
689
- - This is the only meaningful tag for this slot - the total probabilities should sum to 1
690
-
691
- ##### Custom Events
692
-
693
- - `risky-outcome-change`
694
- - Indicates that an outcome has been changed
695
- - `detail`
696
- - `x: number`
697
- - Objective value
698
- - `p: number`
699
- - Probability
700
- - `name: string`
701
- - Name of outcome
702
-
703
- ##### Example
704
-
705
- ```html
706
- <risky-option interactive>
707
- <risky-outcome interactive probability="0.25" value="0" name="loss"></risky-outcome>
708
- <risky-outcome interactive probability="0.75" value="20" name="win"></risky-outcome>`
709
- </risky-option>
710
- ```
711
-
712
- #### `RiskyOutcome` / `<risky-outcome>`
713
-
714
- A single outcome for a decision option (no display on its own)
715
-
716
- A place-holder to specify an outcome with a particular value and probability. Only useable inside of
717
- a `<risky-option>`.
718
-
719
- ##### Attributes
720
-
721
- - `interactive: boolean = false`
722
- - Allow direct manipulation of probabilities and values
723
- - `value: number = 0`
724
- - Objective value
725
- - `probability: number = 0`
726
- - Probability
727
- - `name: string = ''`
728
- - Name for this outcome
729
-
730
- ##### Example
731
-
732
- ```html
733
- <risky-outcome interactive value="20" probability="0.8" name="win"></risky-outcome>
734
- ```
735
-
736
- #### `ProspectableResponse` / `<prospectable-response>`
737
-
738
- Response buttons, feedback, and payoffs for gambling decision tasks
739
-
740
- This element provides 'gamble' and 'sure' response buttons. It can also display a running count
741
- of the trials, display feedback in comparative terms, and payoff outcome.
742
-
743
- ##### Attributes
744
-
745
- - `interactive: boolean = false`
746
- - Allow user to respond, instead of just displaying simulated model responses
747
- - `feedback: string = 'outcome'`
748
- - What type of feedback to display
749
- - Options
750
- - `'none'`
751
- - No feedback
752
- - `'outcome'`
753
- - Feedback in terms of comparative selection, i.e. 'better', 'worse', 'even', or 'no response'
754
- - `trial: boolean = false`
755
- - Display the running count of trials, i.e. 'Trial: 2 of 10'
756
- - `payoff: string = 'none'`
757
- - What payoff information to display
460
+ - `amount: number = 20`
461
+ - Amount of option
462
+ - `delay: number = 5`
463
+ - Delay of option
464
+ - `state: string = 'choice'`
465
+ - Current state of the display
758
466
  - Options
759
- - `'none'`
760
- - No payoff information displayed
761
- - `'selection'`
762
- - Only display payoff for the selected option
763
- - `'both'`
764
- - Display payoffs for both options
765
-
766
- ##### Methods
767
-
768
- - `start(xl, xw, pw, xs, gamblePayoff, surePayoff, better, trial)`
769
- - Indicates that a trial has started, and its time to wait for a response
770
- - Parameters
771
- - `xl: number`
772
- - Objective value of gamble loss
773
- - `xw: number`
774
- - Objective value of gamble win
775
- - `pw: number`
776
- - Probability of gamble win
777
- - `xs: number`
778
- - Objective value of sure thing
779
- - `gamblePayoff: number`
780
- - Actual outcome if gamble is selected
781
- - `surePayoff: number`
782
- - Actual outcome if sure thing is selected
783
- - `better: string`
784
- - Which option is better, either `'gamble'`, `'sure'`, or `'equal'`
785
- - `trial: number`
786
- - The count of the trial within the block
787
- - `stop()`
788
- - Indicates that the trial is over and it is time to display any requested feedback
789
- - **Note:** If no response has been made yet, the trial is recorded as having no response
790
- - `gamble()`
791
- - Emulate a 'gamble' response
792
- - `sure()`
793
- - Emulate an 'sure' response
794
- - `responded(response)`
795
- - Emulate a response
796
- - Parameters
797
- - `response: string`
798
- - Whether to emulate a `'gamble'` or `'sure'` response
799
- - `reset()`
800
- - Reset to the state at the start of a block of trials
467
+ - `'choice'`
468
+ - Show the option quantities
469
+ - `'fixation'`
470
+ - Show blank option
471
+ - `'blank'`
472
+ - Show blank option
801
473
 
802
474
  ##### Custom Events
803
475
 
804
- - `prospectable-response`
805
- - Indicates that a response has been made on this trial
476
+ - `itc-option-change`
477
+ - Indicates that the option has been changed
806
478
  - `detail`
807
- - `trial: number`
808
- - The count of this trial in the block
809
- - `better: string`
810
- - Which option is better, either `'gamble'`, `'sure'`, or `'equal'`
811
- - `gamblePayoff: number`
812
- - Actual outcome if gamble was selected
813
- - `surePayoff: number`
814
- - Actual outcome if sure thing was selected
815
- - `xl: number`
816
- - Objective value of gamble loss
817
- - `xw: number`
818
- - Objective value of gamble win
819
- - `pw: number`
820
- - Probability of gamble win
821
- - `xs: number`
822
- - Objective value of sure thing
823
- - `response: string`
824
- - Whether the response was `'gamble'` or `'sure'`
825
- - `outcome: string`
826
- - The outcome of the trial as `'better'`, `'worse'` or `'even'`
827
- - `payoff: number`
828
- - The payoff for this trial
829
-
830
- ##### Example
831
-
832
- ```html
833
- <prospectable-response interactive feedback="outcome" trial payoff="selection"></prospectable-response>
834
- ```
835
-
836
- #### `DecisionSpace` / `<decision-space>`
837
-
838
- 3D representation of decision space for given parameter values
839
-
840
- A 3D plot, with gamble win value, gamble win probability, and sure value as the three dimensions.
841
- The decisions are between a gamble with a win value with a win probability and a lose value of zero,
842
- and a sure thing with a sure value. Decisions can be represented as points in the space. A surface
843
- can be displayed representing the border between combinations of values and probabilities that will
844
- lead to a 'gamble' choice versus a 'sure' choice.
845
-
846
- Note: This component relies on Plotly's 3d Isosurface and Scatter Plots, which seem to require a few
847
- megabytes of code, and are laggy to update, though direct interaction with the plot is snappy.
848
-
849
- ##### Attributes
850
-
851
- - `surface: boolean = true`
852
- - Should the surface separating 'gamble' choices versus 'sure' choices be displayed
853
- - `point: string = 'first'`
854
- - Should the points representing choices be displayed
855
- - Options
856
- - `'all'`
857
- - Show all choices as points
858
- - `'first'`
859
- - Only show the first choice as a point
860
- - `'rest'`
861
- - Show all but the first choice as points
862
- - `'none'`
863
- - Don't show any choices as points
864
- - `updateable: boolean = false`
865
- - Can the color-coded responses for decisions change based on current parameters
866
- - `alpha: number = 0.8`
867
- - Parameter α (diminishing marginal utility)
868
- - `lambda: number = 1.2`
869
- - Parameter λ (loss aversion)
870
- - `gamma: number = 0.8`
871
- - Parameter γ (probability distortion)
872
- - `win: number = 20`
873
- - Winning value in gamble
874
- - `loss: number = 0`
875
- - Losing value in gamble
876
- - `probability: number = 0.5`
877
- - Probability of *winning*
878
- - `sure: number = 10`
879
- - Sure value
880
-
881
- ##### Methods
882
-
883
- - `get(name = 'default')`
884
- - Retrieve the identified choice
885
- - Parameters
886
- - `name: string = 'default'`
887
- - Identifier for choice
888
- - Return value
889
- - `choice: object` or `null`
890
- - `name: string`
891
- - Identifier for choice
892
- - `xw: number`
893
- - Value of gamble win
894
- - `pw: number`
895
- - Probability of gamble win
896
- - `xs: number`
897
- - Value of sure thing
898
- - `response: string`
899
- - Chosen response
900
- - Options
901
- - 'gamble'
902
- - 'sure'
903
- - `label: string`
904
- - Label
905
- - `set(xw, pw, xs, response, name = 'default', label = '')`
906
- - Create or change the value of the identified choice
907
- - Parameters
908
- - `xw: number`
909
- - Value of gamble win
910
- - `pw: number`
911
- - Probability of gamble win
912
- - `xs: number`
913
- - Value of sure thing
914
- - `response: string`
915
- - Chosen response
916
- - Options
917
- - 'gamble'
918
- - 'sure'
919
- - `name: string = 'default'`
920
- - Identifier for choice
921
- - `label: string = ''`
922
- - Label for choice
479
+ - `a: number`
480
+ - Amount
481
+ - `d: number`
482
+ - delay
923
483
 
924
484
  ##### Example
925
485
 
926
486
  ```html
927
- <decision-space updateable surface="true" point="all" alpha="0.75" lambda="1.2" gamma="0.8" win="20" loss="0" probability="0.5" sure="10"></cpt-space>
487
+ <itc-option interactive amount="75" delay="25" state="choice"></itc-option>
928
488
  ```
929
489
 
930
- #### `RiskyTask` / `<risky-task>`
490
+ #### `ITCTask` / `<itc-task>`
931
491
 
932
- Displays stimuli for gambling decision task
492
+ Displays stimuli for inter-temporal choice task
933
493
 
934
494
  When run, a block of trials is presented. Before each trial is an inter-trial interval (ITI). Each
935
495
  trial then consists of a stimulus during which a participant can respond. The stimulus consists of
936
- two options, each of which is represented as a pie chart. The proportion of the pie represents the
937
- probability, and a number in the pie piece represents the value. The choice is always between a
938
- gamble with a winning value and a losing value, and a sure thing. The task can be paused and then
939
- resumed, and it can also be reset and run again.
496
+ two options, each of which is represented as an amount at a delay.The choice is generally between a
497
+ smaller sooner option and a larger later option. The task can be paused and then resumed, and it can
498
+ also be reset and run again.
940
499
 
941
500
  ##### Attributes
942
501
 
@@ -957,18 +516,18 @@ resumed, and it can also be reset and run again.
957
516
 
958
517
  ##### Custom Events
959
518
 
960
- - `risky-block-start`
519
+ - `itc-block-start`
961
520
  - Indicates the beginning of a block of trials
962
- - `risky-block-end`
521
+ - `itc-block-end`
963
522
  - Indicates the completion of a block of trials
964
- - `detail` for `risky-block-start` and `risky-block-end`
523
+ - `detail` for `itc-block-start` and `itc-block-end`
965
524
  - `trials: number`
966
525
  - Number of trials in the block
967
- - `risky-trial-start`
526
+ - `itc-trial-start`
968
527
  - Indicates the beginning of a trial (iti is over and stimulus is about to start)
969
- - `risky-trial-end`
528
+ - `itc-trial-end`
970
529
  - Indicates the end of a trial (stimulus is over and iti is about to start)
971
- - `detail` for `risky-trial-start` and `risky-trial-end`
530
+ - `detail` for `itc-trial-start` and `itc-trial-end`
972
531
  - `trials: number`
973
532
  - Number of trials in the block
974
533
  - `duration: number`
@@ -977,34 +536,24 @@ resumed, and it can also be reset and run again.
977
536
  - Duration of inter-trial interval in milliseconds
978
537
  - `trial: number`
979
538
  - Count of trial in block (one-based)
980
- - `xl: number`
981
- - Losing value in gamble
982
- - `xw: number`
983
- - Winning value in gamble
984
- - `pw: number`
985
- - Probability of winning gamble
986
- - `xs: number`
987
- - Value of sure thing
988
- - `better: string`
989
- - Which option is better according to expected value
990
- - Options
991
- - `'gamble'`
992
- - `'sure'`
993
- - `'equal'`
994
- - `gamblePayoff: number`
995
- - Payoff for choosing the gamble (based on random outcome)
996
- - `surePayoff: number`
997
- - Payoff for choosing the sure thing
539
+ - `as: number`
540
+ - Amount of smaller sooner option
541
+ - `ds: number`
542
+ - Delay of smaller sooner option
543
+ - `al: number`
544
+ - Amount of larger later option
545
+ - `dl: number`
546
+ - Delay of larger later option
998
547
 
999
548
  ##### Example
1000
549
 
1001
550
  ```html
1002
- <risky-task duration="3000" iti="500" trials="10" running></risky-task>
551
+ <itc-task duration="3000" iti="500" trials="10" running></itc-task>
1003
552
  ```
1004
553
 
1005
554
  ### Equations
1006
555
 
1007
- Interactive equations for CPT
556
+ Interactive equations for HTD
1008
557
 
1009
558
  The equations can either be static and display the variable names, be static and display names and
1010
559
  values or be interactive with names and editable values, in which case only the values on the right
@@ -1014,47 +563,9 @@ side of the equals sign are editable.
1014
563
  screens. Ideally a proper math renderer would be used, but I haven't found one that takes kindly to
1015
564
  insertion of the custom elements needed for live editing.
1016
565
 
1017
- #### `CPTEquationPG2W` / `<cpt-equation-pg2w>`
1018
-
1019
- Subjective decision weight from objective probability and sensitivity
1020
-
1021
- ##### Attributes
1022
-
1023
- - `numeric: boolean = false`
1024
- - Show values instead of just the names of variables
1025
- - `interactive: boolean = false`
1026
- - Allow editing of numeric values in the equation
1027
- - `p: number = 0.75`
1028
- - Probability
1029
- - `g: number = 0.5`
1030
- - Parameter γ (probability distortion)
1031
-
1032
- ##### Properties
1033
-
1034
- - `w: number`
1035
- - Decision weight
1036
-
1037
- ##### Custom Events
1038
-
1039
- - `cpt-equation-pg2w-change`
1040
- - Indicates that the values in the equation have changed
1041
- - `detail`
1042
- - `p: number`
1043
- - New value of probability
1044
- - `g: number`
1045
- - New value of parameter γ (probability distortion)
1046
- - `w: number`
1047
- - New value of decision weight
1048
-
1049
- ##### Example
1050
-
1051
- ```html
1052
- <cpt-equation-pg2w numeric interactive p="0.75" g="0.8"></cpt-equation-pg2w>
1053
- ```
1054
-
1055
- #### `CPTEquationXAL2V` / `<cpt-equation-xal2v>`
566
+ #### `HTDEquationADK2V` / `<htd-equation-adk2v>`
1056
567
 
1057
- Subjective value from objective value, marginal utility, and loss aversion
568
+ Subjective value from objective amount and delay, and a discounting factor
1058
569
 
1059
570
  ##### Attributes
1060
571
 
@@ -1062,314 +573,225 @@ Subjective value from objective value, marginal utility, and loss aversion
1062
573
  - Show values instead of just the names of variables
1063
574
  - `interactive: boolean = false`
1064
575
  - Allow editing of numeric values in the equation
1065
- - `x: number = 10`
1066
- - Objective value
1067
- - `a: number = 0.5`
1068
- - Parameter α (diminishing marginal utility)
1069
- - `l: number = 2`
1070
- - Parameter λ (loss aversion)
576
+ - `amount: number = 100`
577
+ - Amount
578
+ - `delay: number = 30`
579
+ - Delay
580
+ - `k: number = 0.05`
581
+ - Parameter k (discounting factor)
1071
582
 
1072
583
  ##### Properties
1073
584
 
1074
585
  - `v: number`
1075
- - Subjective value
586
+ - Value
1076
587
 
1077
588
  ##### Custom Events
1078
589
 
1079
- - `cpt-equation-xal2v-change`
590
+ - `htd-equation-adk2v-change`
1080
591
  - Indicates that the values in the equation have changed
1081
592
  - `detail`
1082
- - `x: number`
1083
- - New value of objective value
1084
593
  - `a: number`
1085
- - New value of parameter α (diminishing marginal utility)
1086
- - `l: number`
1087
- - New value of parameter λ (loss aversion)
594
+ - New value of amount
595
+ - `d: number`
596
+ - New value of delay
597
+ - `k: number`
598
+ - New value of parameter k (discounting factor)
1088
599
  - `v: number`
1089
- - New value of subjective value
1090
-
1091
- ##### Example
1092
-
1093
- ```html
1094
- <cpt-equation-xal2v numeric interactive x="20" a="0.75" l="2.5"></cpt-equation-xal2v>
1095
- ```
1096
-
1097
- #### `CPTEquationVW2U` / `<cpt-equation-vw2u>`
1098
-
1099
- Subjective utility from subjective value and subjective decision weight
1100
-
1101
- ##### Attributes
1102
-
1103
- - `numeric: boolean = false`
1104
- - Show values instead of just the names of variables
1105
- - `interactive: boolean = false`
1106
- - Allow editing of numeric values in the equation
1107
- - `v: Array = [10, 0]`
1108
- - Subjective values
1109
- - Expressed in HTML as a space-separated list
1110
- - `w: Array = [0.75, 0.25]`
1111
- - Decision weights
1112
- - Expressed in HTML as a space-separated list
1113
- - `n: number = 2`
1114
- - Number of subjective value/decision weight pairs
1115
-
1116
- ##### Properties
1117
-
1118
- - `u: number`
1119
- - Subjective utility
1120
-
1121
- ##### Custom Events
1122
-
1123
- - `cpt-equation-vw2u-change`
1124
- - Indicates that the values in the equation have changed
1125
- - `detail`
1126
- - `v: Array`
1127
- - New values of subjective values
1128
- - `w: Array`
1129
- - New values of decision weights
1130
- - `n: number`
1131
- - Number of subjective value/decision weight pairs
1132
- - `u: number`
1133
- - New value of subjective utility
600
+ - New subjective value
1134
601
 
1135
602
  ##### Example
1136
603
 
1137
604
  ```html
1138
- <cpt-equation-vw2u numeric interactive v="20 0" w="0.25 0.75" n="2"></cpt-equation-vw2u>
605
+ <htd-equation-adk2v numeric interactive amount="20" delay="10" k="0.2"></htd-equation-adk2v>
1139
606
  ```
1140
607
 
1141
- #### `CPTEquation`
608
+ #### `HTDEquation`
1142
609
 
1143
- Base class for all interactive CPT equations
610
+ Base class for all interactive HTD equations
1144
611
 
1145
612
  To define a new equation:
1146
613
 
1147
614
  ```javascript
1148
- export default class CPTEquationSomething extends CPTEquation {
615
+ export default class HTDEquationSomething extends HTDEquation {
1149
616
  ...
1150
617
  }
1151
618
  ```
1152
619
 
1153
- `CPTEquation` extends `ProspectableElement` extends `DecidablesElement` extends `LitElement`
620
+ `HTDEquation` extends `DiscountableElement` extends `DecidablesElement` extends `LitElement`
1154
621
 
1155
622
  ### Examples
1156
623
 
1157
624
  Full examples built from multiple components
1158
625
 
1159
- #### `CPTExampleHuman` / `<prospectable-example-human>`
626
+ #### `HTDExampleHuman` / `<htd-example-human>`
1160
627
 
1161
- User runs task, and results are fit and displayed in real-time using CPT
628
+ User runs task, and results are fit and displayed in real-time using HTD
1162
629
 
1163
- Used to build examples where the user is performing the gambling decision task. Can include
1164
- controls, the task itself, response buttons with feedback and payoffs, the value function, the
1165
- probability function, a 3D visualization of the decisions in the block with the decision surface,
1166
- and trace plots and histograms for the parameters in the model fit. The value function and
1167
- probability function should not be interactive, because their rendering is determined by the user's
1168
- task performance.
630
+ Used to build examples where the user is performing the inter-temporal choice task. Can include
631
+ controls, the task itself, response buttons with feedback, HTD curves, and trace plots and
632
+ histograms for the parameters in the model fit. The HTD curves should not be interactive, because
633
+ their rendering is determined by the user's task performance.
1169
634
 
1170
635
  ##### Slots
1171
636
 
1172
637
  - *unnamed*
1173
- - Place relevant `prospectable-elements` components here
638
+ - Place relevant `discountable-elements` components here
1174
639
  - Wired elements
1175
- - `<cpt-fit>`
1176
- - Fits the user's responses to CPT using a Bayesian model running in a Web Worker
1177
- - `<cpt-probability>`
1178
- - Displays the probability function based on the current model parameters
1179
- - `<cpt-value>`
1180
- - Displays the value function based on the current model parameters
1181
- - `<prospectable-control>`
640
+ - `<discountable-control>`
1182
641
  - Allows user to adjust parameters and control the task
1183
- - `<prospectable-response>`
1184
- - Allows user to make responses and see feedback and payoffs
1185
- - `<decision-space>`
1186
- - Displays all completed trials in block in decision space with the model's decision surface
1187
- - `<risky-task>`
642
+ - `<discountable-response>`
643
+ - Allows user to make responses and see feedback
644
+ - `<htd-fit>`
645
+ - Fits the user's responses to HTD using a Bayesian model running in a Web Worker
646
+ - `<htd-curves>`
647
+ - Displays the options as amounts with delays with discounting curves based on the current
648
+ model parameters
649
+ - `<itc-task>`
1188
650
  - Displays the task
1189
651
 
1190
652
  ##### Example
1191
653
 
1192
654
  ```html
1193
- <cpt-example-human>
1194
- <cpt-fit></cpt-fit>
1195
- <cpt-probability></cpt-probability>
1196
- <cpt-value></cpt-value>
1197
- <prospectable-control trials="10" run pause reset></prospectable-control>
1198
- <prospectable-response interactive trial feedback="outcome" payoff="both"></prospectable-response>
1199
- <decision-space point="rest" alpha="1" lambda="1" gamma="1"></decision-space>
1200
- <risky-task trials="10"></risky-task>
1201
- </cpt-example-human>
655
+ <htd-example-human>
656
+ <discountable-control trials="10" run pause reset></discountable-control>
657
+ <itc-task trials="10"></itc-task>
658
+ <discountable-response interactive trial feedback></discountable-response>
659
+ <htd-curves></htd-curves>
660
+ <htd-fit></htd-fit>
661
+ </htd-example-human>
1202
662
  ```
1203
663
 
1204
- #### `CPTExampleInteractive`
664
+ #### `HTDExampleInteractive` / `<htd-example-interactive>`
1205
665
 
1206
- Explore how decision and CPT model parameters relate
666
+ Explore how decision and HTD model parameters relate
1207
667
 
1208
668
  Used to build examples where the user can explore the relationship between a choice and model
1209
- parameters. Can include the choice, a visual rendering of the comparative utility calculation, the
1210
- value function with the current choice, the probability function with the current choice, a 3D
1211
- visualization of the choice in decision space with the decision surface, and a 3D visualization of
1212
- the choice in CPT model space with the decision surface. All components can be interactive (except
1213
- the 3D visualizations which don't support it).
669
+ parameters. Can include the choice, a visual rendering of the comparative value calculation, and the
670
+ HTD curves with the current options. All components can be interactive.
1214
671
 
1215
672
  ##### Attributes
1216
673
 
1217
674
  **Note:** Since many attributes are set on the example, they don't need to be set on the individual
1218
675
  components, as they will be propagated and kept in sync.
1219
676
 
1220
- - `alpha: number = 0.8`
1221
- - Parameter α (diminishing marginal utility)
1222
- - `lambda: number = 1.2`
1223
- - Parameter λ (loss aversion)
1224
- - `gamma: number = 0.8`
1225
- - Parameter γ (probability distortion)
1226
- - `loss: number = 0`
1227
- - Losing value in gamble
1228
- - `win: number = 20`
1229
- - Winning value in gamble
1230
- - `probability: number = 0.5`
1231
- - Probability of *winning*
1232
- - `sure: number = 10`
1233
- - Sure value
677
+ - `amount-ss: number = 10`
678
+ - Smaller sooner amount
679
+ - `delay-ss: number = 1`
680
+ - Smaller sooner delay
681
+ - `amount-ll: number = 50`
682
+ - Larger later amount
683
+ - `delay-ll: number = 40`
684
+ - Larger later delay
685
+ - `k: number = 0.05`
686
+ - Parameter k (discounting factor)
1234
687
 
1235
688
  ##### Slots
1236
689
 
1237
690
  - *unnamed*
1238
- - Place relevant `prospectable-elements` components here
691
+ - Place relevant `discountable-elements` components here
1239
692
  - Wired elements
1240
- - `<cpt-calculation>`
1241
- - Display and change the utility calculations
1242
- - `<cpt-probability>`
1243
- - Display and change the probability function and gamble decision weight
1244
- - `<cpt-space>`
1245
- - Display the space of possible parameter values with the current values and decision surface
1246
- current decision
1247
- - `<cpt-value>`
1248
- - Display and change the value function and subjective values of gamble win and sure thing
1249
- - `<risky-choice>`
1250
- - Display and change the choice between a gamble and a sure thing
1251
- - `<decision-space>`
1252
- - Display the space of possible decisions with the current decision and the decision surface
693
+ - `<htd-calculation>`
694
+ - Display and change the value calculations
695
+ - `<htd-curves>`
696
+ - Displays the options as amounts with delays with discounting curves based on the current
697
+ model parameters
698
+ - `<itc-choice>`
699
+ - Display and change the choice between smaller sooner and larger later options
1253
700
 
1254
701
  ##### Example
1255
702
 
1256
703
  ```html
1257
- <cpt-example-interactive probability="0.75" win="20" loss="0" sure="10" alpha="0.9" lambda="2" gamma="0.75">
1258
- <risky-choice interactive></risky-choice>
1259
- <cpt-probability interactive></cpt-probability>
1260
- <cpt-value interactive></cpt-value>
1261
- <cpt-calculation numeric interactive></cpt-calculation>
1262
- <cpt-space updateable></cpt-space>
1263
- <decision-space updateable></decision-space>
1264
- </cpt-example-interactive>
704
+ <htd-example-interactive a1="5" d1="20" a2="30" d2="350" k="0.01">
705
+ <itc-choice interactive></itc-choice>
706
+ <htd-curves interactive></htd-curves>
707
+ <htd-calculation numeric interactive></htd-calculation>
708
+ </htd-example-interactive>
1265
709
  ```
1266
710
 
1267
- #### `CPTExampleModel` / `<cpt-example-model>`
711
+ #### `HTDExampleModel` / `<htd-example-model>`
1268
712
 
1269
- Model simulates task based on CPT parameter values
713
+ Model simulates task based on HTD parameter values
1270
714
 
1271
- Used to build examples where the model is simulated to perform the gambling decision task. Can
1272
- include controls, the task itself, response buttons with feedback and payoffs, a visual rendering of
1273
- the comparative utility calculation, the value function with the current choice, the probability
1274
- function with the current choice, and a 3D visualization of the decisions in the block with the
1275
- decision surface. The value and probability functions should be interactive, so the user can modify
1276
- the model. The responses and the 3D visualization should not be interactive, because their values
1277
- are received from the model's task performance.
715
+ Used to build examples where the model is simulated to perform the inter-temporal choice task. Can
716
+ include controls, the task itself, response buttons with feedback, and a visual rendering of the HTD
717
+ curves. The HTD curves should be interactive, so the user can modify the model. The responses should
718
+ not be interactive, because their values are received from the model's task performance.
1278
719
 
1279
720
  ##### Attributes
1280
721
 
1281
722
  **Note:** Since model parameter attributes are set on the example, they don't need to be set on the
1282
723
  individual components, as they will be propagated and kept in sync.
1283
724
 
1284
- - `alpha: number = 0.8`
1285
- - Parameter α (diminishing marginal utility)
1286
- - `lambda: number = 1.2`
1287
- - Parameter λ (loss aversion)
1288
- - `gamma: number = 0.8`
1289
- - Parameter γ (probability distortion)
725
+ - `k: number = 0.2`
726
+ - Parameter k (discounting factor)
1290
727
 
1291
728
  ##### Slots
1292
729
 
1293
730
  - *unnamed*
1294
- - Place relevant `prospectable-elements` components here
731
+ - Place relevant `discountable-elements` components here
1295
732
  - Wired elements
1296
- - `<cpt-calculation>`
1297
- - Display the utility calculations
1298
- - `<cpt-probability>`
1299
- - Display and change the probability function
1300
- - `<cpt-value>`
1301
- - Display and change the value function
1302
- - `<prospectable-control>`
733
+ - `<discountable-control>`
1303
734
  - Allows user to adjust parameters and control the task
1304
- - `<prospectable-response>`
1305
- - Allows user to view model responses, feedback, and payoffs
1306
- - `<decision-space>`
1307
- - Displays all completed trials in block in decision space with the model's decision surface
1308
- - `<risky-task>`
735
+ - `<discountable-response>`
736
+ - Allows user to view model responses and feedback
737
+ - `<htd-calculation>`
738
+ - Display the value calculations
739
+ - `<htd-curves>`
740
+ - Displays the options as amounts with delays with discounting curves based on the current
741
+ model parameter, which can be changed
742
+ - `<itc-task>`
1309
743
  - Displays the task
1310
744
 
1311
745
  ##### Example
1312
746
 
1313
747
  ```html
1314
- <cpt-example-model alpha="0.9" lambda="2" gamma="0.75">
1315
- <prospectable-control trials="10" run pause reset></prospectable-control>
1316
- <risky-task trials="10"></risky-task>
1317
- <cpt-probability interactive></cpt-probability>
1318
- <cpt-value interactive></cpt-value>
1319
- <prospectable-response trial feedback="outcome" payoff="both"></prospectable-response>
1320
- <decision-space updateable point="rest" alpha="1" lambda="1" gamma="1"></decision-space>
1321
- </cpt-example-model>
748
+ <htd-example-model k="0.2" >
749
+ <discountable-control trials="10" run pause reset></discountable-control>
750
+ <itc-task trials="10"></itc-task>
751
+ <htd-curves interactive></htd-curves>
752
+ <discountable-response trial feedback></discountable-response>
753
+ </htd-example-model>
1322
754
  ```
1323
755
 
1324
- #### `CPTExample`
756
+ #### `HTDExample`
1325
757
 
1326
- Base class for all CPT examples
758
+ Base class for all HTD examples
1327
759
 
1328
760
  To define a new example:
1329
761
 
1330
762
  ```javascript
1331
- export default class CPTExampleSomething extends CPTExample {
763
+ export default class HTDExampleSomething extends HTDExample {
1332
764
  ...
1333
765
  }
1334
766
  ```
1335
767
 
1336
- `CPTExample` extends `ProspectableElement` extends `DecidablesElement` extends `LitElement`
768
+ `HTDExample` extends `DiscountableElement` extends `DecidablesElement` extends `LitElement`
1337
769
 
1338
770
  ### Base class
1339
771
 
1340
- #### `ProspectableElement`
772
+ #### `DiscountableElement`
1341
773
 
1342
- Base class for all *prospectable* web components
774
+ Base class for all *discountable* web components
1343
775
 
1344
776
  To define a new element:
1345
777
 
1346
778
  ```javascript
1347
- export default class ProspectableElementSomething extends ProspectableElement {
779
+ export default class DiscountableElementSomething extends DiscountableElement {
1348
780
  ...
1349
781
  }
1350
782
  ```
1351
783
 
1352
- `ProspectableElement` extends `DecidablesElement` extends `LitElement`
784
+ `DiscountableElement` extends `DecidablesElement` extends `LitElement`
1353
785
 
1354
786
  ## Development
1355
787
 
1356
788
  ### Features/Bugs/Notes
1357
789
 
1358
- - Add to CPTMath
790
+ - Add to HTDMath
1359
791
  - Luce choice rule
1360
- - utility from x, p, and parameters
1361
- - Make sure to use corrected formula!
1362
- v(xw) * w(xp) + v(xl) * w(1 - xp) ?><? v(xs)
1363
- (Nilsson, Rieskamp, & Wagenmakers, 2011)
1364
- VERSUS
1365
- v(xw) * w(xp) + v(xl) * 1 - w(xp) ?><? v(xs)
1366
- (Nilsson, Rieskamp, & Wagenmakers, 2020)
1367
- This follows (Tversky & Kahneman, 1992)!
1368
792
 
1369
793
  ### Package Scripts
1370
794
 
1371
- - `yarn gulp preparePlotly`
1372
- - Injects Plotly styles into `src/components/plotly-style.auto.js` for inclusion in components
1373
795
  - `yarn lint`
1374
796
  - Lints scripts in `src/`
1375
797
  - `yarn test`
@@ -1383,7 +805,7 @@ export default class ProspectableElementSomething extends ProspectableElement {
1383
805
 
1384
806
  ### File Organization
1385
807
 
1386
- - `prospectable-elements/`
808
+ - `discountable-elements/`
1387
809
  - `lib/` (Bundles created from `src/` by `build`)
1388
810
  **\[autogenerated\]**
1389
811
  - `src/` (Source files)