nutterb / HydeNet

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

computeUtility() and MEU() #11

Closed jdutch27 closed 9 years ago

jdutch27 commented 9 years ago

computeUtility(decisionNet, policies) MEU(decisionNet, policies)

decisionNet must be "compiled", with coda.samples matrix of posterior samples populated

parameter policies is a data structure containing user-specified combinations of values of the decision nodes (i.e., "policies") in the network. If someone wants to only look at 1 of 3 decision nodes, they just leave the column of the other two decision nodes blank.

Example:

policies = data.frame( goToCollege = c("","","",""), haveKids = c("No","No","Yes","Yes"), moveToAbuDhabi=c("No","Yes","No","Yes") # that used to be a joke )

The column names of the policies data frame must be equal to (or some subset of?) the names of the decision nodes in decisionNet. Maybe we can get away with not needing to specify blank columns though, with a warning message like: "NOTE: no values for the following decision nodes were set in the policies argument to computeUtility(): goToCollege. These decision nodes will be marginalized over in the computation of utilities."?

The computeUtility() function will then repeatedly run JAGS (have a parallel=TRUE parameter, as they did in random.forest?) with the decision nodes set to values of given rows in the policies data frame, outputting (only?) the coda.samples() matrix of nodes that are parents of utility nodes in the network. After JAGS returns, columns represented computed values of the utility nodes can be added to the coda.samples() matrix. Also, a node called totalUtility can then be added which is simply the sum of the utility node values.

MEU just does the same, but does the additional work of returning an appended policies data frame with a column representing expectedUtility (average of the totalUtility column). I guess returning the data frame sorted by expectedUtility would be useful.