| mpt_tree | R Documentation |
Specifies a single tree of a multinomial processing tree model
by naming the tree and providing one branch-probability expression per
response category. Trees created with mpt_tree() are combined into a
full model specification with mpt().
mpt_tree(name, branches, ..., impossible = NULL)
name |
Character. Label for the tree. For models with multiple trees,
the label identifies the tree in the data: the column named by the
|
branches |
Either a named list of character strings or the first of
several formulas. Each list element (or formula) gives the branch
probability expression for one response category; the element names (or
the left-hand sides) are the response categories. The expressions can use
latent parameters (e.g., |
... |
Further formulas of the form |
impossible |
Character vector. Response categories that cannot occur in
this tree, for example distractor responses when no distractors were
presented. Such categories get no branch expression, and the remaining
branches must sum to 1 on their own. It follows |
Nothing in the formulas is evaluated: the left-hand side must be a single response category name, the right-hand side is kept as an expression (with constant arithmetic folded, see below), and the formula environment is dropped. A one-sided formula, a left-hand side that is not a name, and a mix of formulas and strings are errors.
Constant arithmetic such as 1/4 or 1/(2*2) is folded into a
decimal literal (0.25) when the tree is created. Stan compiles a bare
integer fraction as integer division (1/4 == 0), which would silently
corrupt the likelihood.
Categories listed in impossible keep their column in the data and their
place in the response matrix, but their probability is set to zero for the
observations belonging to this tree. Because the model is estimated on the
log scale, "zero" is implemented as a large negative linear predictor
rather than a literal zero; no probability has to be taken away from the
remaining branches to compensate.
An object of class mpt_tree
# the target tree of the two-high-threshold model: targets (studied items)
# end in the responses "old" and "new"
tree_target <- mpt_tree(
"target",
old ~ D + (1 - D) * g,
new ~ (1 - D) * (1 - g)
)
tree_target
# the same tree with the branches as a named list of strings
tree_target_strings <- mpt_tree(
name = "target",
branches = list(
old = "D + (1 - D) * g",
new = "(1 - D) * (1 - g)"
)
)
identical(tree_target, tree_target_strings)
# a three-alternative recognition task in which lures are shown on some
# trials only: `lure` responses cannot occur on the others
tree_lures <- mpt_tree(
"lures",
target ~ D * b + (1 - D) * (1/3),
lure ~ D * (1 - b) + (1 - D) * (1/3),
new ~ (1 - D) * (1/3)
)
# the branches of the lure-free tree sum to 1 without the `lure` category;
# no probability is reserved for it
tree_nolures <- mpt_tree(
"nolures",
target ~ D + (1 - D) * (1/2),
new ~ (1 - D) * (1/2),
impossible = "lure"
)
tree_nolures
# a `tree` column in the data holds "lures" or "nolures" per observation;
# effects of experimental conditions go in the parameter formulas instead,
# e.g. bmf(D ~ 0 + cond)
model <- mpt(list(tree_lures, tree_nolures), tree_id = "tree")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.