nutterb / HydeNet

Hybrid Decision Networks in R
Other
23 stars 3 forks source link

setNode dbern bug #104

Closed jarrod-dalton closed 6 years ago

jarrod-dalton commented 6 years ago

I updated everything to the latest current-devel version, and now setNode doesn't recognize the 'p' parameter for nodeType="dbern":

> net <- setNode(net, pregnant, nodeType="dbern", p=0.2) Error in eval(parse(text = e)) : object 'p' not found

jarrod-dalton commented 6 years ago

I am still getting this error, and fear that I may have over-written your fix to the problem.

This problem persisted when using the CRAN version as well as the current-devel branch installed from source.

> net <- HydeNetwork(~ wells
+   + pe | wells
+   + d.dimer | pregnant * pe
+   + angio | pe
+   + treat | d.dimer * angio
+   + death | pe*treat)
> net <- setNode(network = net, node = pregnant,
+   nodeType = "dbern", p = .4,
+   factorLevels = c("No", "Yes"))
Error in eval(parse(text = e)) : object 'p' not found
> net <- setNode(net, wells, nodeType = "dnorm", mu = 5, tau = 1 / (1.5^2))
Error in eval(parse(text = e)) : object 'mu' not found
jarrod-dalton commented 6 years ago

...ok- i figured out that the bug was in my invocation of setNode. Now, nodeType = "dbern" wants a prob parameter (previously it was p) and nodeType = "dnorm" wants mean and sd parameters (previously it was mu and tau). I think this is fine, although we may eventually wish to incorporate a bit of flexibility (e.g., allowing the user to specify things like p, mu and sigma).

jarrod-dalton commented 6 years ago

I also noticed that our Student's T distribution example doesn't work anymore. I think it may be due to not updating jagsDists table for associated R parameters. I tried doing this, though, and still had problems:

> net <- setNode(net, d.dimer, nodeType = "dt",
+ mu = "210 + 29 * pregnant + 68 * pe", sd = 5, k = 2)
Error in eval(parse(text = e)) : object 'mu' not found

> jagsDists[jagsDists$FnName=="dt",]
    DistName FnName FnNameR xLow xHigh Parameters RParameter paramLimit     paramLogic Rsupport
24 Student t     dt      dt                    mu                       is.numeric(mu)    FALSE
25 Student t     dt      dt                   tau                   > 0        tau > 0    FALSE
26 Student t     dt      dt                     k         df        > 0          k > 0     TRUE
> jagsDists[jagsDists$FnName=="dt","RParameter"]
[1] ""   ""   "df"
> jagsDists[jagsDists$FnName=="dt","RParameter"] <- c("mean","sd","df")

> net <- setNode(net, d.dimer, nodeType = "dt",
+   mean = "210 + 29 * pregnant + 68 * pe", sd = 5, df = 2)
Error in eval(parse(text = e)) : object 'mu' not found
> net <- setNode(net, d.dimer, nodeType = "dt",
+   mu = "210 + 29 * pregnant + 68 * pe", sd = 5, df = 2)
Error in eval(parse(text = e)) : object 'mu' not found
nutterb commented 6 years ago

This is effectively the same issue as Issue #100, and has been fixed in 0.10.7