Skip to content

Commit

Permalink
fix renaming of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nutterb committed Jan 20, 2018
1 parent 55b82b1 commit 5bb17f9
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: HydeNet
Type: Package
Title: Hybrid Bayesian Networks Using R and JAGS
Version: 0.10.7
Version: 0.10.8
Author: Jarrod E. Dalton <daltonj@ccf.org> and Benjamin Nutter
<benjamin.nutter@gmail.com>
Maintainer: Benjamin Nutter <benjamin.nutter@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion R/Hyde-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' probability distributions, where each node represents a random variable and
#' each edge represents conditionality. The full joint distribution is
#' therefore factorized as a product of conditional densities, where each node
#' is assumed to be independent of its non-desendents given information on its
#' is assumed to be independent of its non-descendants given information on its
#' parent nodes. Since exact, closed-form algorithms are computationally
#' burdensome for inference within hybrid networks that contain a combination
#' of continuous and discrete nodes, particle-based approximation techniques
Expand Down
2 changes: 1 addition & 1 deletion R/HydeNetwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#' to fitter functions.
#' \item \code{nodeParams} A named list. Each element is a vector of parameters
#' that will be expected by JAGS.
#' \item \code{fromData} A named list with the logical value of wheather parameters
#' \item \code{fromData} A named list with the logical value of whether parameters
#' should be estimated from the data.
#' \item \code{nodeData} A named list with the data for each node. If a node's
#' entry in \code{fromData} is \code{TRUE} and \code{nodeData} is \code{NULL},
Expand Down
5 changes: 3 additions & 2 deletions R/compileJagsModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ compileJagsModel <- function(network, data=NULL, ...)

cpt_arrays <- makeCptArrays(network) #* The utilty function is in the
#* file for compileDecisionModel

jags <-
rjags::jags.model(
file = textConnection(writeNetworkModel(network)),
data =
if (is.null(data) & length(cpt_arrays) == 0)
{
sys.frame(sys.parent())
sys.frame(sys.parent())
# .GlobalEnv
}
else
{
Expand Down
26 changes: 26 additions & 0 deletions R/expectedVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,29 @@ expectedParameters <- function(network, node, returnVector=FALSE)
)
}
}


expectedParameters_ <- function(network, node, returnVector=FALSE)
{
inputs <- network[["nodeType"]][[node]]

params <- jagsDists[["RParameter"]][jagsDists[["FnName"]] == inputs]

names(params) <- jagsDists[["Parameters"]][jagsDists[["FnName"]] == inputs]

if (returnVector)
{
return(params)
}
else
{
cat(
paste(
paste(
paste0(params, "= "),
collapse=", "
)
)
)
}
}
2 changes: 1 addition & 1 deletion R/setNode.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
#' The validation of parameters is performed by comparing the values provided with
#' the limits defined in the \code{jagsDists$paramLogic} variable. (look at
#' \code{data(jagsDists, data='HydeNet')}. For most node types, validation will
#' be peformed for numeric variables. For deterministic variables, the validation
#' be performed for numeric variables. For deterministic variables, the validation
#' will only check that the parameter definition is a formula.
#'
#' It is possible to pass character strings as definitions, but when this is done,
Expand Down
Binary file removed R/sysdata.Rda
Binary file not shown.
15 changes: 6 additions & 9 deletions R/writeJagsModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ writeJagsModel <- function(network, node)
node_params <- network[["nodeParams"]][[node_str]]

params <-
eval(
substitute(
expectedParameters(network = network,
node = node,
returnVector = TRUE
)
)
)

expectedParameters_(network = network,
node = node,
returnVector = TRUE)

names(node_params) <- names(params)

switch(
network[["nodeType"]][[node_str]],
"dbern" = writeJagsModel_dbern(network = network,
Expand Down
18 changes: 5 additions & 13 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
This update fixes errors introduced with `DiagrammeR` 0.9.0

This is a resubmission to address issues found regarding links in the vignettes.
The links have been updated. The link to another package on CRAN now uses
https. The other problematic link does not have an https equivalent. I did,
however, write some tests to check that links to this page (rules for a card
game) are valid so that I may catch this problem before submission in the future.
This update provides fixes to design features that failed to meet the specification design. It permits the user to define distribution parameters using either the R distribution function argument, or the JAGS distribution function argument.

## Test environments
* win-builder (release)
* local windows install R 3.3.2
* local windows install R-devel 2017-01-05 r71919
* win-builder (devel 2017-09-12 r73242)
* Local Linux install R 3.4.3 (Ubuntu 16.05.3 LTS)
* Travis CI Linux install R 3.4.2 (Ubuntu 14.04.5 LTS)

## R CMD check results

A NOTE was returned by win-builder (release and devel) regarding
potential spelling errors; all words in the DESCRIPTION file are
correctly spelled.
There were no findings from the CHECK results

## Downstream dependencies
There are no downstream dependencies for this package
Expand Down
2 changes: 1 addition & 1 deletion man/Hyde-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/HydeNetwork.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/setNode.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/DecisionNetworks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ net <- setNodeModels(net, glm.hit1, glm.hit2, glm.hit3)

Alternatively, decision nodes can be deterministic in nature. In this case, we interpret the function which sets the value of these nodes depending on the value(s) of its parent node(s) as a deterministic strategy that is chosen by the actor. Within the blackjack network, we might envision such a strategy by the following rule, which would be applicable to all three hit decisions in the network: choose 'hit' when the current point total is less than 15.

**Utility nodes** are restricted to be deterministic nodes with no descendents. In the blackjack example, for instance, we would assign the payoff utility node as follows:
**Utility nodes** are restricted to be deterministic nodes with no descendants. In the blackjack example, for instance, we would assign the payoff utility node as follows:

```{r}
net <- setNode(net, payoff, "determ", define=fromFormula(),
Expand Down

0 comments on commit 5bb17f9

Please sign in to comment.