HydeUtilities: Hyde Network Utility Functions

Description Usage Arguments Details Author(s)

Description

The functions described below are unexported functions that are used internally by HydeNet to prepare and modify network objects and prepare JAGS code.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
termName(term, reg)

decisionOptions(node, network)

makeJagsReady(mdl, factorRef, bern)

matchLevelNumber(t, lev)

matchVars(terms, vnames)

nodeFromFunction(node_fn)

policyMatrixValues(node, network)

polyToPow(poly)

validateParameters(params, dist)

makeFactorRef(network)

dataframeFactors(dataframe)

factor_reference(data)

Arguments

term

Usually the term column from the output of broom::tidy()

reg

A regular expression, usually provided by factorRegex

node

Character string indicating a node in a network

network

A Hyde Network Object

mdl

Output from broom::tidy()

factorRef

A list of data frames mapping factors to levels

bern

bernoulli node names.

t

Usually the term_name column generated within makeJagsReady

lev

usually the level_value column generated within makeJagsReady

terms

A vector of term names, usually from a broom::tidy object.

vnames

A vector of term names, usually from network$nodes.

node_fn

A character string representing a function passed in a model formula

poly

A single term for which the polynomial components should be converted to the JAGS pow() function.

params

The list of parameters given in the ... argument of setNode

dist

The JAGS distribution function name. Appropriate names are in the FnName column of the jagsDists data object.

dataframe

A data frame. The data frame will be searched for factors and a reference table (another data frame) is returned.

data

A data frame.

Details

termName: In most model objects, factors in the model are represented as [variable][level]. This utility function pulls out the [variable] component. This is typically called from within makeJagsReady.

decisionOptions: When compiling multiple JAGS models to evaluate the effect of decision nodes, the options for each decision node are extracted by this utility.

makeJagsReady: Manages the presence of factors in interactions and makes sure the proper numeric factor value is given to the JAGS code. This is called from within a writeJagsFormula call.

matchLevelNumber: Assigns the correct numeric value of a level to a factor variable in a model. This is called from within makeJagsReady.

matchVars: Given a list of existing node names, the terms of a formula are matched to the node names. This allows functions to be used in formula defintions. Most commonly, factor(var) would get reduced to var, which is a node name that JAGS will understand. There is still limited ability for translation here, and matchVars assumes that the longest match is the desired match. If you pass a function with two node names, the longer of the two will be taken and JAGS will likely fail.

nodeFromFunction: This is a utility function necessary to make modelToNode work properly. A node vector was needed to pass to matchVars, and this is the mechanism to generate that vector.

polyToPow: converts polynomials generated by the poly function to use the pow function in JAGS.

validateParameters: Users may pass parameters to the JAGS code using the setNode function. If a faulty parameter is given, such as lambda = -10 for a poisson distribution (lambda must be positive in a Poisson distribution), the error returned by JAGS may not clear enough to diagnose a problem that presented several steps earlier in the code. validateParamters allows the user to receive instant feedback on the appropriateness of the code.

Logical expressions for comparisons are stored in the jagsDists data object (data(jagsDists, package='Hyde')). This is a utility function used only within setNode and is not visible to the user.

Author(s)

Jarrod Dalton and Benjamin Nutter


HydeNet documentation built on July 8, 2020, 5:15 p.m.