policyMatrix: Construct Policy and Decision Matrices

Description Usage Arguments Details Value Author(s) Examples

View source: R/PolicyMatrix.R

Description

It may be of interest to compare posterior distributions of variables dependent on differing levels of the decision nodes. For example, how might choosing a different engine in a car affect the fuel consumption. policyMatrix provides a quick utility to begin defining the policy matrix on which decisions can be made.

Usage

1
2
3
policyMatrix(network, ..., useDefaultPolicies = TRUE)

defaultPolicyMatrix(network)

Arguments

network

A HydeNetwork object

...

Named arguments with vectors of the policy values.

useDefaultPolicies

A logical indicating if the default policy values from decision nodes should be used for any decision nodes not named in .... If a node is named in ... and also has default policy values, the user supplied values take precedence.

Details

When ... is not used, the default policy matrix is defined as all possible combinations of the levels in the network's decision nodes. If no decision nodes are defined, an error is returned. Note that the default policy matrix returns JAGS-ready values, which are numeric according to the level number of a factor. In user-defined matrices, character values are supported and will be converted to numerics when the JAGS model is compiled.

Semi-custom policy matrices can be defined by providing the values of each node to be considered. When manually supplying values, the nodes must exist in network, but the requirement that they be decision nodes is not enforced. Thus, it is possible to include numeric values in a decision matrix.

Policy matrices can be passed to HydeSim to run posterior distributions on each row of the policy matrix. There is nothing particularly special about the policy matrices returned by policyMatrix; they are simply data frame that require names drawn from the nodes in the network. Any data frame can be passed to HydeSim and a check is done there to confirm all of the column names match a node in the network.

Whenever a node is identified as a deterministic node, its policy values are forced to NULL, regardless of what the user has specified.

Value

Returns a data frame built by expand.grid and intended to be used with HydeSim.

Author(s)

Jarrod Dalton and Benjamin Nutter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(PE, package="HydeNet")
Net <- HydeNetwork(~ wells + 
                     pe | wells + 
                     d.dimer | pregnant*pe + 
                     angio | pe + 
                     treat | d.dimer*angio + 
                     death | pe*treat,
                     data = PE) 
                     

                 
Net <- setDecisionNodes(Net, angio, treat)
plot(Net)

policyMatrix(Net)

policyMatrix(Net, treat="No", angio = c("No", "Yes"))

nutterb/HydeNet documentation built on July 13, 2020, 5:21 p.m.