regddm {RegDDM}R Documentation

Bayesian hierachical generalized linear regression using Drift-Diffusion Model

Description

regddm makes it easy to fit a single Bayesian hierarchical drift-diffusion model (DDM) that estimates the DDM parameters of each subject and uses the estimated parameters as variables in a generalized linear regression.

Usage

regddm(
  data1,
  data2,
  model = list(),
  family = "gaussian",
  init = "default",
  prior = TRUE,
  stan_filename = "",
  gen_model = TRUE,
  fit_model = TRUE,
  warmup = 500,
  iter = 1000,
  chains = 4,
  cores = 4,
  ...
)

Arguments

data1

Subject-level dataframe with column such as age and gender. It must contain an id column unique for each subject.

data2

Trial-level dataframe. It must contain three columns: id, response and rt. It can also contain additional trial-level variables such as experiment condition.

model

A list containing 0-5 formulas, specifying the dependence structure between variables.

family

Family of distribution of y. Can be gaussian, bernoulli or poisson.

init

Either default or other values supported by stan function of RStan

prior

A losigtic value, specifying whether or not to use default prior for DDM parameters. By default, prior = TRUE.

stan_filename

A string specifying the automatically generated stan file name. By default, an empty string '' is provided. A temporary file will be created and deleted after the model is fit.

gen_model

A logistic value indicating weather or not to generate the model. If not, RegDDM will not generate the code but use the existing stan code from stan_filename instead.

fit_model

A logistic value indicating weather or not to fit the model. If not, RegDDM will only generate the code and return an unfitted regddmfit object.

warmup

Number of warm-up iterations. Default is 500.

iter

Number of iterations, which must be greater than warmup. Default value is 1000.

chains

Number of chains to run for diagnosis. Default value is 4.

cores

Number of cores to run the chains. It is best to make cores = chains. Default value is 4.

...

Other parameters sent to stan function of RStan.

Value

A regddmfit object.

References

To be added

Examples

# Note: each example takes about 20 minutes to run. During this period, you
# may not be able to open/save files or see the progress. To prevent this,
# it is recommended to copy, paste and run the example code in the console.

## Not run: 
# Example analysis over the simulated tutorial dataset.
data(regddm_tutorial)
model = list(v ~ x1, y ~ v_0 + v_x1 + c1)
fit1 = regddm(
  regddm_tutorial$data1,
  regddm_tutorial$data2,
  model,
  stan_filename = ""
)
print(fit1)

# Alternatively, subjects' DDM parameters can be used as the outcome.
model = list(v ~ x1, v_x1 ~ y + c1)
fit2 = regddm(
  regddm_tutorial$data1,
  regddm_tutorial$data2,
  model,
  stan_filename = ""
)
print(fit2)

## End(Not run)

[Package RegDDM version 1.0 Index]