Reaction | R Documentation |
An R6 class representing a reaction (chance) edge in a decision tree.
A specialism of class Arrow
which is used in a decision tree
to represent edges whose source nodes are ChanceNode
s.
rdecision::Edge
-> rdecision::Arrow
-> Reaction
new()
Create an object of type Reaction
. A probability
must be assigned
to the edge. Optionally, a cost and a benefit may be associated
with traversing the edge. A pay-off (benefit-cost) is sometimes
used in edges of decision trees; the parametrization used here is more
general.
Reaction$new( source_node, target_node, p = 0, cost = 0, benefit = 0, label = "" )
source_node
Chance node from which the reaction leaves.
target_node
Node which the reaction enters.
p
Conditional probability of traversing the reaction edge. At most one Reaction from each chance node may have this set to 'NA_real_', in which case it will be replaced by one minus the sum of conditional probabilities of the other reaction edges from the node.
cost
Cost associated with traversal of this edge (numeric or
ModVar
), not NA.
benefit
Benefit associated with traversal of the edge (numeric or
ModVar
), not NA.
label
Character string containing the reaction label.
A new Reaction
object.
grob()
Creates a grid::grob for a reaction edge.
Reaction$grob(xs, ys, xt, yt, fs = 0.2)
xs
x coordinate of source of edge, grid::unit object.
ys
y coordinate of source of edge, grid::unit object.
xt
x coordinate of target of edge, grid::unit object.
yt
y coordinate of target of edge, grid::unit object.
fs
Fraction of the edge which slopes.
A grid::grob containing the symbol and label.
modvars()
Find all the model variables of type ModVar
that
have been specified as values associated with this Action. Includes
operands of these ModVar
s, if they are expressions.
Reaction$modvars()
A list of ModVar
s.
set_probability()
Set the probability associated with the reaction edge.
Reaction$set_probability(p)
p
Conditional probability of traversing the reaction edge. Of type
numeric or ModVar
. If numeric, p
must be in the range
[0,1], or NA_real_
. Note that setting p = NA
will cause
an error.
Updated Reaction
object.
p()
Return the current value of the edge probability, i.e., the conditional probability of traversing the edge.
Reaction$p()
Numeric value in range [0,1].
set_cost()
Set the cost associated with the reaction edge.
Reaction$set_cost(c = 0)
c
Cost associated with traversing the reaction edge. Of type
numeric or ModVar
.
Updated Reaction
object.
cost()
Return the cost associated with traversing the edge.
Reaction$cost()
Cost.
set_benefit()
Set the benefit associated with the reaction edge.
Reaction$set_benefit(b = 0)
b
Benefit associated with traversing the reaction edge. Of type
numeric or ModVar
.
Updated Action
object.
benefit()
Return the benefit associated with traversing the edge.
Reaction$benefit()
Benefit.
clone()
The objects of this class are cloneable with this method.
Reaction$clone(deep = FALSE)
deep
Whether to make a deep clone.
Andrew J. Sims andrew.sims@newcastle.ac.uk
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.