About RNetica

RNetica is best thought of as a "glue" layer between the open source statistical programing language R http://www.r-project.org/ and the proprietary Bayesian network engine Netica ® http://www.norsys.com/. Although there are some minor extensions to the Netica API, the primary purpose of RNetica is to provide a binding for the Netica API functions inside of R.

There are two big advantages to this. One is that while the Netica GUI is helpful for model development, entering evidence by point and click is cumbersome for real work. Embedding the Netica API within R means that R can be used for data preparation and cleaning, the data can be entered into a model developed with the Netica GUI and the results extracted and graphed using the graphical power of R. The second big advantage is that R is an interpreted language, which supports rapid improvisation of code. This make it substantially faster to work in RNetica than using the C or Java APIs.

Getting Started

I recently did a demonstration of RNetica for my Bayes net class and recorded it using Tegrity. I'm posting a few of those resources here as a way of getting started.

News

There is now an RNetica user survey. I want to count my users so I can tell the funding agencies they should give me more money to work on it. Click here to fill out the survey.

A new 0.5 series of releases is planned. Basically, I'm trying to redo the basic NeticaBN and NeticaNode classes as true R6 classes rather than S3 classes wrapped around symbols. There will be some significant advantages, including automatic loading of node objects for networks, and the ability to refer to networks by name within a session object. Potentially, also, multiple session possiblities, and I'm hoping a more stable code base. Finally, by storing the symbol to node mapping in a local environment (hash table) instead of the Netica callback, I'm hoping to make the system more robust to some mysterious erros I'm seeing crop up.

The current development is taking place on a fork in the SVN repository.

  1. The branch RNetica-XP (I meant to type XR, for Extending R, but I made a typo.) Current version has the S3 objects converted to the new R6 objects, but is documentation and testing is not complete.
  2. The original (0.4 series) code is archived on the branch RNeticaS3. That branch will continue to mark the old version when the RNeticaXR becomes the active branch.

The 0.4 series of releases are now in maintenance mode. The 0.4 series of releases includes the following improvements:

  1. Added the functions MutualInfo, NodeExpectedValue and VarianceOfReal (user request, plus close to the top of my personal list).
  2. Minimal support for equation. (I find the CPTtools easier to use for manipulating conditional probability tables.)
  3. Added more functions for decision nets, although these are not currently working (support request in to Norsys).
  4. A few other functions related to calcuating values and interval and Gaussian findings. Again, these are not working in the 0.4-1 version and a help request to Norsys is pending.
  5. Added some random findings generation code.
  6. Cleaned up the behavior of as.IDname() so that it makes shorter names and is properly vectorized.
  7. Fixed some minor errors and problems with error handling.
  8. Added a new cc() function (and methods for c()) to keep c() from dropping attributes. (Only partially successful; RNetica 0.5 should fix this problem.).

The 0.3 series of releases includes a number of different improvements.

  1. I now how official permission to distribute binary versions from Norsys. (You may want to still download and compile from sources you need the latest version of the API.)
  2. RNetica now passes the self-test under gctorture(TRUE), which should mean that is it is much more robust to memory errors. This is still a beta version, caution is still advisable.
  3. UpdateIt now has case file support and includes support for learning conditional probability tables
  4. I've moved my development and testing platform to R 3.0.1. Binaries are build for R version 3.x.
  5. Update The version 0.3 cycle is more or less complete, except that I'm waiting for API updates from Norsys in response to problems.

Known issues with this release.

  1. There is currently no way through the Netica API to check whether EM and Gradient decent learning converged or timed out due to the maximum number of iterations being reached.
  2. Currently, memory streams cannot be used with the LearnCPTs functions. This appears to be a Netica problem.
  3. As I'm going through the compile cycle, I'm running into some errors under Windows related to generating extra error messages after the first error message or warning. Haven't had time to track this down yet. Problem seems to only affect the 32-bit Windows version (anybody still use that?).
  4. The functions EnterIntervalFinding and EnterGaussianFinding seem to give probabity 1 to a single state no matter the width of the interval or the SD.
  5. The functions CalcNodeValue and CalcNodeState return NA when I think they should return a non-missing value.
  6. The function NodeExpectedUtils is generating an internal Netica error.
  7. The function CreateNetwork (and probably the load network functions as well) assume that StartNetica() has been called. Normally, library(RNetica) call StartNetica(), but if you bypass the normal library() mechanism, CreateNetwork() will give a Seg Fault error instead of a sensible error message.
  8. If a node has a name which is too close to the 30 character limit, and that node is disconnected from a link, leaving a stub variable, then the stub variable will have a name that is longer than 30 characters, causing problems. To avoid make sure names are no more than 26 characters. UPDATE. Changed as.IDname() to make shorter names.

Approximately 4/5 of the API functionality is mapped. Things that are still not mapped:

  1. Testers
  2. DBN functionality
  3. Database suppot (I see no need to do this as better to use the DBI R package).

RNetica License Information

There are three layers to the complete RNetica environment, each with their own licensing terms.

  1. The R Programming Language is released under the GNU General Public License (GPL) version 2. See the R FAQ for more information.
  2. The Netica API is a commercial product. License terms can be found on the Norsys® web site.
  3. RNetica itself (the combination of R and C code that provides the glue between R and Netica) is made available under the Artistic License, version 2.0.
I am not a lawyer, and therefore this should not be considered formal legal advise, but my understanding is that for most uses the use of RNetica requires the purchase of a Netica API license (which is different from the Netica GUI license) from Norsys.

Once you have obtained a license key from Norsys, you can use it in one of two ways. First, it can be passed as an argument to the function StartNetica(license key) (you may need to call StopNetica() first). Second, if you execute the command NeticaLicenseKey <- license key in the main R workspace (the default namespace), then RNetica will use that value when loaded through library(RNetica).

Without the license key, the Netica API operates in a limited mode. All of the functions in the test scripts will run, but the size of the networks is generally limited.

Current Version Status

The current version (0.4-6) incorporates approximately 75% of the Netica C API Version 5.04 (no new version since 2012). This is sufficient functionality to build, compile and carry out inferences with a Bayesian network. Some of the more advanced functionality, including support for databases, influence diagrams, and dynamic Bayesian networks is not yet developed.

Although an extensive test script exists for RNetica (most of this is exposed on the manual pages), the testing away from these simple tests has been particularly light. In particular, I have not yet used valgrind to test for memory leaks. It is currently a beta release. Note that because it uses calls to C code, it is possible for RNetica to crash R. Plan your work accordingly.

The development has been with R version 3.0.1–3.4.1 under Ubuntu 16.04 with Netica API 5.04. R CMD check RNetica runs under Mac OS X and Windows 7 without errors. Almost all of the testing has been with the 64 bit versions of R and Netica. There may be some problems that crop up under 32 bit versions.

Version 0.2-7 was developed and tested under R 2.15.2. The windows binary for that version is a R 2.15 binary.

RNetica Releases

The following releases are archived here:

ReleaseSourceWindowsMacOSManualNotes
0.1-8RNetica_0.1-8.tar.gz First reasonably functional version.
0.2-5RNetica_0.2-5.tar.gz Initial version used for Newton's Playground
0.2-6RNetica_0.2-6.tar.gz RNetica-manual_0.2-6.pdfFixed Windows installation.
0.2-7RNetica_0.2-7.tar.gz RNetica_0.2-7.zip RNetica_0.2-7.tgz RNetica-manual_0.2-7.pdf Last Version for R 2.15
0.3-1RNetica_0.3-1.tar.gz RNetica-manual_0.3-1.pdf R 3.0: Added NodeExperience and Case Writing (not Reading)
0.3-3RNetica_0.3-3.tar.gz RNetica_0.3-3.zip RNetica_0.3-3.tgzRNetica-manual_0.3-3.pdf R 3.0: Support for Case Streams (file and memory)
0.3-4RNetica_0.3-4.tar.gz RNetica_0.3-4.zip RNetica_0.3-4.tgzRNetica-manual_0.3-4.pdf Learning CPTs
0.4-1RNetica_0.4-1.tar.gz RNetica_0.4-1.zip RNetica_0.4-1.tgzRNetica-manual_0.4-1.pdf Equations, Decisions, Continuous Nodes and Mutual Information
0.4-2RNetica_0.4-2.tar.gz RNetica_0.4-2.zip RNetica_0.4-2.tgzRNetica-manual_0.4-2.pdfRandom Findings Generation, as.IDname() cleanup, bug fixes
0.4-4RNetica_0.4-4.tar.gz RNetica_0.4-4.zip RNetica_0.4-4.tgzRNetica-manual_0.4-4.pdfPeanut compatability, User Object support
0.4-5RNetica_0.4-5.tar.gz RNetica_0.4-5.zip RNetica_0.4-5.tgz RNetica-manual_0.4-5.pdf Peanut compatability, User Object support
0.4-6RNetica_0.4-6.tar.gz RNetica_0.4-6.zip RNetica_0.4-6.tgz RNetica-manual_0.4-6.pdf Added cc() function and c() methods.

Note the source versions have been compiled and tested under Linux/Unix, Mac OS X and Windows. Note that for Windows and Mac OS X, compiling source packages requires the R development kit to be installed. See the appropriate R FAQ for your operating system. You should also be familiar with building R packages, see the Writing R Extensions manual.

Compiling from sources requires that you have already downloaded and unpacked the Netica C API from Norsys. Under *nix (including Mac OS X) the location of the library can be passed to the configure command, e.g.:

R CMD INSTALL RNetica --configure-args='--with-netica=/Users/ralmond/software/Netica_API_504/'

Under Windows (or as an alternative to the --with-netica switch), the environmental variable NETICA_HOME can be set to the location in which the Netica API was unpacked. I have only tested with the API version 5.04, not with earlier versions.

Although I am now supplying Windows and Mac OS X binaries, which include the Netica API (currently version 5.04). As this is still an early test release, it will help you to have a local R guru to ask support questions, and help file bug reports if needed. NOTE: this is an unlicensed version of the API: you still need to purchase a license (although the unlicensed version will run the sample code in the man pages).

A recent communication with Brent indicated that a new Netica API will be out soon. When that comes out, there will likely be a big update.

Development Version

The latest development version is available as a subversion repository at: https://pluto.coe.fsu.edu/svn/common/RNetica/.

If you have patches or other correspondence about RNetica you can contact me at almond@acm.org. If you are filing a bug report, please be sure to include the following information:

  1. The version number of CPTtools and R that you are using.
  2. Your operating system and whether it is 64 or 32 bit.
  3. The exact text of any error message that is generated.
  4. A small script that reproduces the problem (if at all possible).

Legal Notices

Netica and Norsys are registered trademarks of Norsys, LLC, used by permission.

Although Norsys has been generally supportive of the RNetica project, they do not offer formal support in any way. (In particular, the do not currently have anybody on staff who knows R.) All support requests should be sent to the package maintainers.

The software is offered AS IS, without any warranty of any kind. Support is provided on a volunteer basis, and may not be immediately forthcoming.


Site last updated on 2017-08-01.