Code Monkey home page Code Monkey logo

dbn's People

Contributors

nutterb avatar

Watchers

 avatar  avatar  avatar

dbn's Issues

Propagate time horizontally

In the expanded plot view, the time propagates vertically. It is more customary to propagate horizontally.

All dynamic nodes should have the same `max_t`

Change the dbn object to so that every dynamic node references an object-wide value for max_t.

set_node_maxt will not longer be relevant. Replace with set_maxt.

Making nodes dynamic will no longer need to check for a max_t value.

Model specification with time lags

Assume the model:

g <- dbn(map[t] | map[t-1]*map[t-2]*map[t-3], maxt=3)

Wouldn't we require at least 3 initial time steps worth of data to even be able to do the simulations?

In general, we need to figure out the largest time lag specified in the model - call this quantity L (L=3 in the above network).

In order to be able to run the simulations, our predict.dbn() function would need to require that the values for times 0:(L-1) have all been provided as inputs by the user. Then the function would simulate the system over times L:maxt. Obviously this would require some logic to ensure that maxt>=L.

Things to do next

I won't open a new issue for this each time. I'll just keep adding checkboxes to make sure I do things in the right order (and write the appropriate documentation and tests before I move on to the next task)

  • review functional requirements for model_form_to_node_form
  • write tests for model_form_to_node_form
  • Write functional requirements for dbn.formula
  • Write tests for dbn.formula
  • Write functional requirements for dbn.list
  • Write tests for dbn.list
  • Figure out how to use a method internally without exporting it
  • Develop print method for dbn
  • Develop plot method for dbn

Return section in `dbn`

I've left this section largely blank. It will need detail added when we've finalized its structure.

Model to node validation

If I'm going to skip building the models at the time the network is built, I'll need some sort of validation that the model the user passes has the same variables as the parents. so

  • validate_model_to_node

See dag_structure for hints on getting the variable names from the formula. Compare these to the node_attrs node_name and parent columns.

Description in `dbn` needs content

As of 28 October, 2016 it reads

Generate a Dynamic Bayesian Network. This section needs more detail as well. As the crux of the package, perhaps a brief introduction to the topic and its application. Maybe wait until the first vignette is written, and copy content from there?

Initial Structure

I suspect the initial setup will be similar to HydeNet.

We will need an object on which to act, so let's call that dbn. It will need the following attributes

  • network formula (the call?)
  • adjacency matrix
  • node attributes table (for this, I'm considering leveraging tibble (tbl_df) objects, which allow and models to be stored in the table)

The node attributes need to include

  • node name
  • parents
  • is_decision
  • is_utility
  • is_temporal (FALSE means it's a global variable, such as sex)
  • model

Rather than gathering all of the information to build a model, let's instead have them directly insert the model. If we aren't pushing the simulation out to JAGS, we don't need as diverse an object to accommodate direct JAGS coding.

The only immediate downside I see to this is it won't let use simulate from models for which we don't have an object; such as a published model. I'm not quite sure how to handle that yet.

Need a formula and a list method.

  • formula method
  • list method

We will have to restrict the use of xtabs to a single variable. Unless I can be given a reasonable interpretation of what a multivariable xtabs should look like in a network.

  • xtabs with more than one variable prohibited.

dbn.list

Model types

  • xtabs
  • lm
  • glm
  • ols
  • lrm
  • multinom
  • cph
  • coxph
  • survreg

Prediction approach

The node_attr object needs a new column for predict_fn. when a node model is set, if a valid predict method is available, the predict.object_type could be given as a default.

The user can define his or her own prediction function. We will need a set_node_predict_fn. This is how we can define deterministic nodes without a model.

Return the object in a list. First element is data for non-dynamic nodes.

Additional elements at each time point of the dynamic nodes(?).

Provide a tidy method to bring all the elements together into a two dimensional tidy data frame.

plot.dbn

  • Implement custom edges
  • Implement defaults?
  • Write functional requirements
  • Include links to good documentation on node parameters
  • Include links to good documentation on edge parameters
  • Include links to good documentation on global parameters
  • Write unit tests for requirement 5
  • Write unit tests for requirement 8
  • Write documentation about making custom node definitions, particularly, using the node_* notation.
  • Review code and comment it appropriately
  • Provide link to good documentation about colors
  • come up with a way to generate a png or pdf for use in markdown to pdf scripts
  • make examples
  • Fix the edge star notation!

Plotting bug: adding dependencies to time [t-k], where k>=2

g <- dbn(~ age[t]|age[t-1]
         + map[t]|age[t-1]*antihypertensives[t-1]*race*map[t-1]*map[t-2]*map[t-3]*map[t-4]
         + antihypertensives[t] | antihypertensives[t-1]*map[t-1]
         + hdl[t]|age[t-1]*statins[t-1]*race*hdl[t-1], 
         max_t = 5)
plot(g)
plot(g, expand=TRUE)

Observe the lines between map nodes below.

plot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.