Description Usage Arguments Details Value References See Also Examples

Hierarchical Bayesian Modeling of the Risk Aversion Task with the following parameters: "rho" (risk aversion), "tau" (inverse temperature).

**MODEL:** Prospect Theory (Sokol-Hessner et al., 2009, PNAS), without loss aversion (LA) parameter

1 2 3 4 |

`data` |
A .txt file containing the data to be modeled. Data columns should be labeled as:
"subjID", "gain", "loss", "cert", "gamble". See |

`niter` |
Number of iterations, including warm-up. Defaults to 4000. |

`nwarmup` |
Number of iterations used for warm-up only. Defaults to 1000. |

`nchain` |
Number of Markov chains to run. Defaults to 4. |

`ncore` |
Number of CPUs to be used for running. Defaults to 1. |

`nthin` |
Every |

`inits` |
Character value specifying how the initial values should be generated. Options are "fixed" or "random", or your own initial values. |

`indPars` |
Character value specifying how to summarize individual parameters. Current options are: "mean", "median", or "mode". |

`modelRegressor` |
Export model-based regressors? TRUE or FALSE. Currently not available for this model. |

`vb` |
Use variational inference to approximately draw from a posterior distribution. Defaults to FALSE. |

`inc_postpred` |
Include trial-level posterior predictive simulations in model output (may greatly increase file size). Defaults to FALSE. |

`adapt_delta` |
Floating point value representing the target acceptance probability of a new
sample in the MCMC chain. Must be between 0 and 1. See |

`stepsize` |
Integer value specifying the size of each leapfrog step that the MCMC sampler can
take on each new iteration. See |

`max_treedepth` |
Integer value specifying how many leapfrog steps the MCMC sampler can take
on each new iteration. See |

`...` |
Not used for this model. |

This section describes some of the function arguments in greater detail.

**data** should be assigned a character value specifying the full path and name (including
extension information, e.g. ".txt") of the file that contains the behavioral data-set of all
subjects of interest for the current analysis. The file should be a **tab-delimited** text
file, whose rows represent trial-by-trial observations and columns represent variables.

For the Risk Aversion Task, there should be 5 columns of data with the
labels "subjID", "gain", "loss", "cert", "gamble". It is not necessary for the columns to be in this particular order,
however it is necessary that they be labeled correctly and contain the information below:

- "subjID"
A unique identifier for each subject in the data-set.

- "gain"
Possible (50%) gain outcome of a risky option (e.g. 9).

- "loss"
Possible (50%) loss outcome of a risky option (e.g. 5, or -5).

- "cert"
Guaranteed amount of a safe option. "cert" is assumed to be zero or greater than zero.

- "gamble"
If gamble was taken, gamble == 1; else gamble == 0.

*****Note: The file may contain other columns of data (e.g. "ReactionTime", "trial_number",
etc.), but only the data within the column names listed above will be used during the modeling.
As long as the necessary columns mentioned above are present and labeled correctly, there is no
need to remove other miscellaneous data columns.

**nwarmup** is a numerical value that specifies how many MCMC samples should not be stored
upon the beginning of each chain. For those familiar with Bayesian methods, this is equivalent
to burn-in samples. Due to the nature of the MCMC algorithm, initial values (i.e. where the
sampling chains begin) can have a heavy influence on the generated posterior distributions. The
`nwarmup`

argument can be set to a high number in order to curb the effects that initial
values have on the resulting posteriors.

**nchain** is a numerical value that specifies how many chains (i.e. independent sampling
sequences) should be used to draw samples from the posterior distribution. Since the posteriors
are generated from a sampling process, it is good practice to run multiple chains to ensure
that a reasonably representative posterior is attained. When the sampling is complete, it is
possible to check the multiple chains for convergence by running the following line of code:
`plot(output, type = "trace")`

. The trace-plot should resemble a "furry caterpillar".

**nthin** is a numerical value that specifies the "skipping" behavior of the MCMC sampler,
using only every `i == nthin`

samples to generate posterior distributions. By default,
`nthin`

is equal to 1, meaning that every sample is used to generate the posterior.

**Control Parameters:** `adapt_delta`

, `stepsize`

, and `max_treedepth`

are
advanced options that give the user more control over Stan's MCMC sampler. It is recommended
that only advanced users change the default values, as alterations can profoundly change the
sampler's behavior. Refer to 'The No-U-Turn Sampler: Adaptively Setting Path Lengths in
Hamiltonian Monte Carlo (Hoffman & Gelman, 2014, Journal of Machine Learning Research)' for
more information on the sampler control parameters. One can also refer to 'Section 34.2. HMC
Algorithm Parameters' of the Stan User's Guide
and Reference Manual, or to the help page for `stan`

for a less technical
description of these arguments.

A class "hBayesDM" object `modelData`

with the following components:

`model`

Character value that is the name of the model ("ra_noLA").

`allIndPars`

Data.frame containing the summarized parameter values (as specified by

`indPars`

) for each subject.`parVals`

List object containing the posterior samples over different parameters.

`fit`

A class

`stanfit`

object that contains the fitted Stan model.`rawdata`

Data.frame containing the raw data used to fit the model, as specified by the user.

Sokol-Hessner, P., Hsu, M., Curley, N. G., Delgado, M. R., Camerer, C. F., Phelps, E. A., & Smith, E. E. (2009). Thinking like a Trader Selectively Reduces Individuals' Loss Aversion. Proceedings of the National Academy of Sciences of the United States of America, 106(13), 5035-5040. http://www.pnas.org/content/106/13/5035

We refer users to our in-depth tutorial for an example of using hBayesDM: https://rpubs.com/CCSL/hBayesDM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
## Not run:
# Run the model and store results in "output"
output <- ra_noLA("example", niter = 2000, nwarmup = 1000, nchain = 4, ncore = 4)
# Visually check convergence of the sampling chains (should look like 'hairy caterpillars')
plot(output, type = "trace")
# Check Rhat values (all Rhat values should be less than or equal to 1.1)
rhat(output)
# Plot the posterior distributions of the hyper-parameters (distributions should be unimodal)
plot(output)
# Show the WAIC and LOOIC model fit estimates
printFit(output)
## End(Not run)
## Not run:
# Paths to data published in Sokol-Hessner et al. (2009)
path_to_attend_data <- system.file("extdata", "ra_data_attend.txt", package = "hBayesDM")
path_to_regulate_data <- system.file("extdata", "ra_data_reappraisal.txt", package = "hBayesDM")
## End(Not run)
``` |

hBayesDM documentation built on Jan. 21, 2019, 5:04 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.