RNetica is best thought of as a "glue" layer between the open source statistical programming 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.
[]opertators are used in a way that breaks backwards compatability. The
operator is used to manipulate CPTs for probabilistic nodes and the
[]operator is used to manipulate value tables for deterministic (logical) nodes.
operators work. Now
[<-always manipulate CPTs for probabilistic nodes. This should fix a problem with being unable to use the
to set CPTs for continuous nodes that have been discritized.
[[<-operators now focus on manipulating the the value tables for deterministic nodes.
[[...]]expression is no longer a synnonmym for
[[...,drop=TRUE]]. This may break some code but it should be straightforward to fix.
testNetworkfunction which can be used to calculate evidentiary power of the networks.
str, which generates a warning in RStudio. This is harmless, but I'll add
strmethods in the future.
NeticaSessionobject as a container for the link to the Netica session. This also serves as a container for all of the networks included in a session and a wrapper for the license key.
DefaultNeticaSessionin the global environment is referenced.
NeticaSessionas an argument. These include the high level functions
ReadNetworks. A session argument is also needed by some lower level functions which create Netica objects:
NewNeticaRNG. In all cases, if no session argument is supplied the value of
DefaultNeticaSessionis used instead.
NeticaRNGare now R reference classes (a special case of S4 classes) instead of strings with with attributes including an S3 class string. This should prove more robust as certain R functions (in particular,
c()) which stripped the attributes.
as.characterfor networks and nodes now returns a string of the form
<Type: Name>instead of the name of the object. Use the expression
obj$Nameto get the name of the object.
as.characterhas unexpected results when applied to a list of nodes (or presumably nets). In stead of recursively applying the proper
as.charactermethod for the class, it applies a default method which returns
<S4 object of type \"NeticaNode">. Use
match(node, nodelist)no longer works as expected. This appears to be a bug in R as
matchturns objects into strings before matching, but the bug in
as.characterwhen applied to a list produces unexpected results. Use
NodeParent) would sometimes return a non-R object (e.g.,
FALSE). In the new system network objects are cached in the
NeticaSessionobject and node objects are cached in the
NeticaSessionobject. This can be used in a read-only way by RNetica users. In particular,
session$nets$netname, where netname is the Netica name of the network, can be used to reference a network in a session.
NeticaBNobject. Again, this can be used in a read-only way, e.g.,
CreateNetwork) or read into RNetica (
ReadNetworks). R objects are only created and registered with the cache in the network when first accessed. Calling the function
NetworkAllNodeson the network will create R objects for all nodes in the network and register them.
CaseStreamobject is now an abstract class, with two concrete subclasses:
MemoryCaseStream. Again, these are now represented as reference class objects and not strings with attributes, so they should be more robust.
CaseMemoryStream()(note that the name of the constructor is not the name of the class) require a session attribute.
MemoryCaseStreamhas been renamed name from "CaseSMemorytreamm". The constructor is still
CaseMemoryStream()(this now matches the pattern used for
MemoryCaseStreamobjects with some RNetica functions (notably
LearnCPTs). For the moment, it is safer to stick with the files which seem to work better.
CaseStreamobjects are closed when the session is stopped, but it is safer to use
WithOpenCaseStreamto ensure closure.
restartSession()(which take a session object as an argument) handle this.
session <- NeticaSession(LicenseKey="keystring")followed by
sessionis an object stored in the R global workspace, the first step only needs to be executed the first time RNetica is used, the second will be available thereafter.
StartNeticacreates a new Netica session and starts it. The function
StopNeticastops the default session (unless given an argument).
DefaultNeticaSessionto the session object. The function
getDefaultSession()provides the default for most functions where a session argument is required. This uses the value of
DefaultNeticaSession, starting it if it is currently closed. If the value is unset, the user will be prompted (in an interactive session) to create a value for this variable (using the value of
NeticaLicenseKeyif it exists) to create one.
NeticaSessionobject. Do not share licensed session objects with people who are not authorized to use that license key.
NeticaBNobjects (as well as case stream and rng objects) have back pointers to the session object (the field
NeticaNodeobjects have back pointers to the network objects (field
$Net). This should be mostly transparent to users.
The 0.4 series of releases includes the following improvements:
The 0.3 series of releases includes a number of different improvements.
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.
Known issues with this release.
Approximately 4/5 of the API functionality is mapped. Things that are still not mapped:
There are three layers to the complete RNetica environment, each with their own licensing terms.
Updated! Once you have obtained a license key from Norsys, the license is used by executing the following lines of code:
session <- NeticaSession(LicenseKey="Code from Norsys") startSession(session)where session can be replaced with any legal R identifier. Note that if
DefaultNeticaSessionis used as the identifier, most functions that need session arguments will accept this value instead. See the help for
StartNetica()for alternative ways of using the License key. (Backwards compatibility is currently there.) Note that the Netica license key is stored in plain text in the
NeticaSessionobject. Do not share that object (e.g., through sharing R dump files) with somebody who is not authorized to use that license.
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.
The current version (0.5-4) incorporates approximately 75% of the Netica C API Version 5.04 (5.10 for Windows). 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.5.3 under Ubuntu
16.04--18.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.
The following releases are archived here:
|0.1-8||RNetica_0.1-8.tar.gz||First reasonably functional version.|
|0.2-5||RNetica_0.2-5.tar.gz||Initial version used for Newton's Playground|
|0.2-6||RNetica_0.2-6.tar.gz||RNetica-manual_0.2-6.pdf||Fixed Windows installation.|
|0.2-7||RNetica_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-1||RNetica_0.3-1.tar.gz||RNetica-manual_0.3-1.pdf||R 3.0: Added NodeExperience and Case Writing (not Reading)|
|0.3-3||RNetica_0.3-3.tar.gz||RNetica_0.3-3.zip||RNetica_0.3-3.tgz||RNetica-manual_0.3-3.pdf||R 3.0: Support for Case Streams (file and memory)|
|0.4-1||RNetica_0.4-1.tar.gz||RNetica_0.4-1.zip||RNetica_0.4-1.tgz||RNetica-manual_0.4-1.pdf||Equations, Decisions, Continuous Nodes and Mutual Information|
|0.4-2||RNetica_0.4-2.tar.gz||RNetica_0.4-2.zip||RNetica_0.4-2.tgz||RNetica-manual_0.4-2.pdf||Random Findings Generation, as.IDname() cleanup, bug fixes|
|0.4-4||RNetica_0.4-4.tar.gz||RNetica_0.4-4.zip||RNetica_0.4-4.tgz||RNetica-manual_0.4-4.pdf||Peanut compatibility, User Object support|
|0.4-5||RNetica_0.4-5.tar.gz||RNetica_0.4-5.zip||RNetica_0.4-5.tgz||RNetica-manual_0.4-5.pdf||Peanut compatibility, User Object support|
|0.4-6||RNetica_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.|
|0.5-1||RNetica_0.5-1.tar.gz||RNetica_0.5-1.zip||RNetica_0.5-1.tgz||RNetica-manual_0.5-1.pdf||New Object model; new Session objects.|
|0.5-2||RNetica_0.5-2.tar.gz||RNetica_0.5-2.zip||RNetica_0.5-2.tgz||No updates to manual||Minor Bug fix..|
|0.5-4||RNetica_0.5-4.tar.gz||RNetica_0.5-4.zip||RNetica_0.5-4.tgz||RNetica-manual-0.5-4.pdf||Moved as.CPA and as.CPF to CPTtools, now depends on CPTttols|
|0.7-1||RNetica_0.7-1.tar.gz||RNetica_0.7-1.zip||RNetica_0.7-1.tgz||RNetica-manual-0.7-1.pdf||Changed the way  and [] work, and added NetworkTester||0.7-2||RNetica_0.7-2.tar.gz||RNetica_0.7-2.zip||RNetica_0.7-2.tgz||RNetica-manual-0.7-2.pdf||Added str.XXX methods (avoid warning in RStudio)||0.7-3||RNetica_0.7-3.tar.gz||RNetica_0.7-3.zip||RNetica_0.7-3.tgz||RNetica-manual-0.7-3.pdf||NodeLevels can now be in increasing or decreaing order. Node experience is forced to real to prevent c-level errors.|
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
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 (or later) 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.
The latest development version is available as a subversion repository at: https://pluto.coe.fsu.edu/svn/common/RNetica/trunk/. There is also a branch corresponding to the old object model at: https://pluto.coe.fsu.edu/svn/common/RNetica/branches/RNeticaS3.
If you have patches or other correspondence about RNetica you can contact me at firstname.lastname@example.org. If you are filing a bug report, please be sure to include the following information:
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.