readEQN: Read multiTree files

View source: R/readEQN.R

readEQNR Documentation

Read multiTree files

Description

Function to import MPT models from standard .eqn model files as used, for instance, by multiTree (Moshagen, 2010).

Usage

readEQN(file, restrictions = NULL, paramOrder = FALSE, parse = FALSE)

Arguments

file

The (full path to the) file that specifies the MPT model (standard .eqn syntax). Note that category labels must start with a letter (different to multiTree) and match the column names of data. Alternatively, the EQN-equations can be provided within R as a character value (see examples). Note that the first line of an .eqn-file is reserved for comments and always ignored.

restrictions

Specifies which parameters should be (a) constant (e.g., "a=b=.5") or (b) constrained to be identical (e.g., "Do=Dn") or (c) treated as fixed effects (i.e., identical for all participants; "a=b=FE"). Either given as the path to a text file with restrictions per row or as a list of restrictions, e.g., list("D1=D2","g=0.5"). Note that numbers in .eqn-equations (e.g., d*(1-g)*.50) are directly interpreted as equality constraints.

paramOrder

if TRUE, the order of MPT parameters as interally used is printed.

parse

whether to return a parsed MPT model description in terms of the matrices a and b (the powers of the \theta and (1-\theta), respectively, and the vector of constants c. Each branch probability is then given as c_{i} \prod_{s} \theta^{a_{i,s}}(1-\theta)^{b_{i,s}})

Details

The file format should adhere to the standard .eqn-syntax (note that the first line is skipped and can be used for comments). In each line, a separate branch of the MPT model is specified using the tree label, category label, and the model equations in full form (multiplication sign * required; not abbreviations such as a^2 allowed).

As an example, the standard two-high threshold model (2HTM) is defined as follows:

Target Hit Do
Target Hit (1-Do)*g
Target Miss (1-Do)*(1-g)
Lure FalseAlarm (1-Dn)*g
Lure CorrectReject (1-Dn)*(1-g)
Lure CorrectReject Dn

Value

for the default setting parse = FALSE, the function returns a data.frame with the following columns:

  • Tree: the tree label

  • Category: the category label (must match the columns in the data set)

  • Equation: the model equation without parameter restrictions

  • EQN: the model equation with restricted parameters replaced

Author(s)

Daniel Heck, Denis Arnold, Nina Arnold

References

Moshagen, M. (2010). multiTree: A computer program for the analysis of multinomial processing tree models. Behavior Research Methods, 42, 42-54.

Examples

# Example: Standard Two-High-Threshold Model (2HTM)
EQNfile <- system.file("MPTmodels/2htm.eqn",
  package = "TreeBUGS"
)
readEQN(file = EQNfile, paramOrder = TRUE)

# with equality constraint:
readEQN(
  file = EQNfile, restrictions = list("Dn = Do", "g = 0.5"),
  paramOrder = TRUE
)

# define MPT model directly within R
model <-
  "2-High Threshold Model (2HTM)
  old hit d
  old hit (1-d)*g
  old miss (1-d)*(1-g)
  new fa (1-d)*g
  new cr (1-d)*(1-g)
  new cr d"
readEQN(model, paramOrder = TRUE)

denis-arnold/TreeBUGS documentation built on May 13, 2024, 6:34 p.m.