nutterb / HydeNet

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

Decision and Utility Nodes #10

Closed jdutch27 closed 9 years ago

jdutch27 commented 9 years ago

Decision nodes act like regular random variables. Only later functions like MEU() (maximum expected utility) will leverage the fact that they are decision nodes (e.g., creating a policy matrix). So we just need to the following for decision nodes:

1) Create a list object within the HydeNetwork object that stores which nodes are decision nodes. 2) Modify the plot method for HydeNetwork objects to make decision nodes square with white background and some color text 3) Modify the plot method for compiledHydeNetwork objects to make observed decision nodes square with some color background. Could simply invert the colors above in (2).

Utility nodes are a little trickier.

nutterb commented 9 years ago

Decision nodes are implemented in 0.7.2.

For utility nodes, I suppose I only need to add a Utility flag?

jarrod-dalton commented 9 years ago

Well, they need to be deterministic functions of parent nodes which produce numeric vectors. They aren't allowe to have children. And, all utility nodes in the network need to produce utility vectors with the same number of dimensions.

On the last point, some little function or function argument or list element or whatever which allows the user to put labels on the "slots" within the utility vectors (e.g. c("cost", "qalys")) might be helpful.

That's what currently comes to mind, at least.

nutterb commented 9 years ago

Utility nodes exist in version 0.7.3

jdutch27 commented 9 years ago

Not that it matters much, but I thought I’d mention gRbase::children() as a potential function to use in your error checking for utility nodes within setNode():

net <- HydeNetwork(~ card1.ace | card1

plot(g)

children("payoff", net$dag)

NULL

children("initialPoints", net$dag)

[1] "hit1" "pointsAfterCard3" "playerFinalPoints"

From: Benjamin [mailto:notifications@github.com] Sent: Friday, April 24, 2015 12:01 PM To: nutterb/HydeNet Cc: Dalton, Jarrod Subject: Re: [HydeNet] Decision and Utility Nodes (#10)

Utility nodes exist in version 0.7.3

— Reply to this email directly or view it on GitHubhttps://github.com/nutterb/HydeNet/issues/10#issuecomment-95978346.

Please consider the environment before printing this e-mail

Cleveland Clinic is ranked as one of the top hospitals in America by U.S.News & World Report (2014).
Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations.

Confidentiality Note: This message is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy.

Thank you.

jdutch27 commented 9 years ago

Installed updated package and it can't find the setUtilityNodes function. Do the lines

' @rdname setUtilityNodes

' @export

need to be added?

jarrod-dalton commented 9 years ago

With version 0.8.0, it can find the function and appears to run it. However, the list element network$nodeUtility does not appear to get populated:

net <- HydeNetwork(~ card1.ace | card1
                   + card2.ace | card2
                   + initialPoints | card1*card2*card1.ace*card2.ace
                   + hit1 | initialPoints*dealerUpcard
                   + card3 | hit1
                   + card3.ace | card3
                   + pointsAfterCard3 | initialPoints*card3*card3.ace
                   + hit2 | pointsAfterCard3*dealerUpcard
                   + card4 | hit2
                   + card4.ace | card4
                   + pointsAfterCard4 | pointsAfterCard3*card4*card4.ace
                   + hit3 | pointsAfterCard4*dealerUpcard
                   + card5 | hit3
                   + card5.ace | card5
                   + pointsAfterCard5 | pointsAfterCard4*card5*card5.ace
                   + playerFinalPoints | initialPoints*hit1*pointsAfterCard3
                                         *hit2*pointsAfterCard4*hit3*pointsAfterCard5
                   + dealerFinalPoints | dealerUpcard
                   + payoff | playerFinalPoints*dealerFinalPoints)
net <- setDecisionNodes(net, hit1, hit2, hit3)
net <- setUtilityNodes(net, payoff)

net$nodeUtility
NULL
nutterb commented 9 years ago

That's because I seem to have named it nodeUtlity. I'll fix the spelling in the morning