nutterb / HydeNet

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

Add-on: Construct hydeNetwork objects by simply passing a list of model objects #1

Closed jdutch27 closed 9 years ago

jdutch27 commented 9 years ago

It would read the regression equations from the model objects and make the network using the predictors in the model equations.

We would still need to input the prior distributions for the predictor variables.

nutterb commented 9 years ago

It seems like it may be worthwhile to make HydeNetwork a generic function with methods HydeNetwork.formula and HydeNetwork.list. That way the same call with the two different inputs could have vastly different behaviors.

This opens the question now of whether the Hyde objects should have nodeModel attributes. If the model is already built, it seems wasteful to have to refit the model when we generate that JAGS code, especially if we're getting into large data sets.

The question that comes after that is: at what point in the HydeNetwork.formula flow do we generate the models and attach them to the object? I wouldn't want to do that in HydeNetwork.formula, because the user may make changes with setNode. But now that I write it out, it might be reasonable to fit the model in setNode.

nutterb commented 9 years ago

My checklist to make this happen correctly Bold indicates completion

  1. Redefine HydeNetwork as a generic
  2. Redefine HydeNetwork.formula as a method
  3. The first argument in HydeNetwork will be renamed model
  4. For each model type (lm, glm, multinom, and xtabs) write a method to extract the following attributes
    • nodes (the name of the response variable)
    • parents (the independent variables)
    • nodeType (the default nodeType for the response type. Should agree with the defaults in HydeNetwork.formula
    • nodeFitter (the fitting function)
    • nodeFitterArgs (all arguments besides the formula argument)
    • nodeParams (the output from writeJagsFormula..this will prevent refitting of models when bulding the JAGS code)
    • fromData (always TRUE)
    • nodeData (model matrix)
    • nodeModel (the model object)
  5. Generate dag object in HydeNetwork.list
  6. Add nodeData and nodeModel to HydeNetwork.formula. Default to NULL for each node.
  7. Add argument to setNode: fitModel=FALSE. When TRUE, it will fit the model during the setNode run, fill in the nodeParams. Default of FALSE delays all of the fitting until the JAGS model is written. (perhaps set this as a global option? options(Hyde_fitModel=FALSE)
  8. Adapt writeJagsFormula to first look in nodeData and then data when using fromData().
nutterb commented 9 years ago

Changes are implemented. Now to test and fix the bugs.