Difference between revisions of "Category:OpasnetUtils"

From Testiwiki
Jump to: navigation, search
m (General tools: fixed link)
(OpasnetUtils features)
Line 3: Line 3:
  
 
==OpasnetUtils features==
 
==OpasnetUtils features==
[[Modelling in Opasnet]] is done using R and the OpasnetUtils package provides most of the actual tools. Most of the package revolves around the ovariable-class.  
+
[[Modelling in Opasnet]] is done using R and the OpasnetUtils package provides most of the actual tools. Most of the package revolves around the [[Ovariable]]-class.  
  
===Ovariables===
 
The ovariable is a class defined by OpasnetUtils. It has eight separate "slots" that can be accessed using X@slot:
 
*name
 
**Name of <self> is a requirement since R doesn't support self reference.
 
*output
 
**Current definition of <self>.
 
**A single data.frame (a 2D table type in R)
 
**Not defined until <self> is evaluated.
 
*data
 
**A single data.frame that defines <self> as such.
 
**May include textual regular expressions that describe probability distributions which can be interpreted by [[OpasnetUtils/Interpret]].
 
*marginal
 
**A logical vector that indicates full marginal indices of @output.
 
*formula
 
**A function that defines <self>.
 
**Should return either a data.frame or an ovariable.
 
*dependencies
 
**A data.frame that contains names and Rtools or Opasnet tokens/identifiers of variables required for using @formula.
 
**Dependencies will be fetched and evaluated upon <self> evaluation.
 
*ddata
 
**A string containing an Opasnet identifier (i.e. Op_en1000).
 
**This identifier is used to download data from the Opasnet database for the @data slot upon <self> evaluation.
 
 
The general nature of ovariables means that they should not be modified to match a specific model but rather define the variable in question as extensively as possible under it's scope. To match the scope of specific models variables can be modified by supplying orders upstream (outwards in the recursion tree). These orders are checked for upon evaluation. For example decisions in decision analysis can be supplied this way:
 
#pick an endpoint
 
#make decision variables for any upstream variables
 
#evaluate endpoint
 
#optimize between options defined in decisions.
 
Other orders include: collapse of marginal columns by sums, means or sampling to reduce data size and passing input from model level without redefining the whole variable. It is also possible to redefine any specific variable before starting the recursive evaluation, in which case the recursion stops at the defined variable (dependencies are only fetched if they do not already exist to avoid unnecessary computation).
 
 
===Utilising ovariables===
 
 
Defining and analyzing endpoints of a model can be as easy as Fetching a relevant variable, evaluating it (using EvalOutput) and using some of the available functions (i.e. summary() for ovariables).  
 
Defining and analyzing endpoints of a model can be as easy as Fetching a relevant variable, evaluating it (using EvalOutput) and using some of the available functions (i.e. summary() for ovariables).  
  

Revision as of 12:50, 27 August 2013


OpasnetUtils features

Modelling in Opasnet is done using R and the OpasnetUtils package provides most of the actual tools. Most of the package revolves around the Ovariable-class.

Defining and analyzing endpoints of a model can be as easy as Fetching a relevant variable, evaluating it (using EvalOutput) and using some of the available functions (i.e. summary() for ovariables).

...

List/Glossary of package contents

Find more about each function or method using ?<topic> in the R console or search the #Manual. Topics are in approximate order of prevalency.

Ovariable functionalities

  • EvalOutput - is the method used to evaluate ovariables.
  • ComputeDependencies - is automatically run when evaluating ovariables to fetch and evaluate any dependencies they have.
  • CheckMarginals - is automatically run when evaluating ovariables to check the marginal status of output indices.
  • CheckInput - is automatically run when evaluating ovariables to incorporate input definitions if available.
  • CheckCollapse - is automatically run when evaluating ovariables. Uses CollapseMarginal if orders are present.
  • CheckDecisions - is automatically run when evaluating ovariables. Adds scenarios to output if their definitions are present.
  • CollapseMarginal - is used to streamline large models by removing indices through summation etc.

Assessment tools

  • DecisionTableParser - parses scenarios used in decision analysis from data.frames.
  • CollapseTableParser - parses collapse orders from data.frames.
  • Optimize - finds optimal combination of index values.
  • Minimize - finds optimal combination of index values so that the resulting value is minimal.

Custom methods for Opasnet and ovariables

  • oprint - prints a data.frame or the output of an ovariable as a html formatted table so it looks nice on the web page.
  • oapply - uses tapply on ovariable output. Instead of defining INDEX you can define cols as the column names you want to remove.
  • orbind - uses rbind on the output slots two ovariables. Differing columns are allowed (missing ones are added automatically).
  • combine - is similar to orbind, but more efficient and combines source columns.
  • merge - merges ovariable outputs.
  • summary - provides common statistics about the data using tapply. Defaults to describing the distribution about each ovariable index.
  • plot - plots ovariable output. Defaults to comparison of data and formula results.
  • Ops - methods for mathematical operations between ovariables (i.e. X * Y).
  • Math - methods for single variable mathematical operations (i.e. exp(X)).

External (serverside) data and objects

  • opbase.data - downloads data from the Opasnet database.
  • opbase.upload - uploads data to the Opasnet database.
  • opbase.locations - downloads the index information of a particular dataset.
  • opbase.obj.exists - checks whether object (as identified by page identifier) exists in the database.
  • opbase.series - downloads list of datasets for a particular object.
  • opasnet.data - downloads data from any file uploaded to Opasnet as text.
  • opasnet.csv - downloads data from any .csv file uploaded to Opasnet.
  • objects.get - downloads saved R objects matching a key.
  • objects.latest - downloads latest saved R objects matching a code block in Opasnet.
  • objects.put - uploads R objects. Returns key.
  • objects.store - uploads public R objects in Opasnet code block.
  • objects.encode - encrypts R objects.
  • objects.decode - decrypts R objects.

General tools

  • Ovariable - constructs ovariables. More feature than new("ovariable", ...).
  • Fetch - downloads saved R objects in batch fashion.
  • tidy - makes common adjustments to data.frames used for ovariable data slots.
  • interpret - forms a probability distributions based on regular expressions OpasnetUtils/Interpret.
  • result - accesses the result column of the output slot of an ovariable. Result(X) <- y -shortcut is possible.
  • ddata_apply - updates data slot of an ovariable based on a link in the ddata slot. Does not overwrite unless force_ddata = TRUE.
  • convert.units - is a unit conversion engine.
  • fillna - looks for empty column values (NA) in specified data.frame columns and replaces them with all other values in the same column.
  • dropall - cleans factors of unused levels.

Health impact assessment

  • GIS.Exposure - does spatial exposure mapping.
  • GIS.Concentration.matrix - does spatial concentration mapping based on point emission.

Installation

OpasnetUtils is available for any platforms capable for running R from the CRAN repository. Use the drop down menu in the RGui or the R command install.packages("OpasnetUtils") to download the most recent official release.

SVN repository

If you would like to acquire the most recent version, you are welcome to download and compile our source code which is available at https://www.opasnet.org/svn/opasnet_utils/trunk/. For most recent function definitions see the R sub folder. Compilation on Windows machines requires R tools (See the CRAN homepage for more information).

Manual

File:OpasnetUtils-manual.pdf