hex-head.png

R Workflow

 

Getting ubiquity

R

First you’ll need to install R, so go over to CRAN and grab the correct version for your system.

RStudio

It’s not required but RStudio is a decent IDE and it’s helpful if you want to deploy your models as a Shiny App. You can get the free Desktop version and it will let you take advantage of all of elements of the ubiquity R workflow.

Perl

You will need to have access to perl. If you’re running ubiquity on OS X or any other Unix based system (like Linux), it should have an interpreter installed already. On Windows ubiquity is tested with Strawberry Perl (http://strawberryperl.com/), a free perl environment for Windows.

To make sure you have perl installed you can open a command window (Windows) or a terminal (Unix) and type:

perl -v

And you should see something like the following:

This is perl 5, version….

Compiled Code

Ubiquity makes use of compiled code to significantly speed up simulations and parameter estimation. If you’re working on Linux, you will probably already have all of the proper tools installed. On OS X it is easiest to install Xcode and XQuartz.

On Windows you will need to install Rtools (https://cran.r-project.org/bin/windows/Rtools/). After installing these you may need to update your search path:

  • Open the Control Panel

  • Go to “System Properties”

  • Open the “Advanced” tab

  • Select “Environment Variables”

  • Choose the “PATH”

  • Add the following paths:

    • If you're using R version 4: 
      • C:\rtools40\usr\bin 
    • If you're using a previous version of R:
      • C:\Rtools\bin

Getting Ubiquity

Option 1: Install the ubiquity package. The benefit here is that you’ll have access to the vignettes and function documentation. If you’re mainly working in R and don’t need to go back and forth between Matlab, this is probably the method you want to use.

You can install the package from CRAN:

install.packages("ubiquity")

Or you can install the development version off of GitHub:

install.packages("devtools") 
devtools::install_github("john-harrold/ubiquity",                                       
              force           = TRUE,
              build           = TRUE, 
              build_vignettes = TRUE,
              build_opts      = c("--no-resave-data", "--no-manual"))

Once you install the package you can list the vignettes available:

vignette(package="ubiquity")

And view them:

vignette(package="ubiquity", topic="Simulation")

Option 2: You can also install ubiquity as a set of stand alone scripts by downloading a template (https://template.ubiquity.tools), unzipping it and you’re good to go. The benefit here is that you can work in an environment where you can move back and forth between R and Matlab. Some organizations may control what packages you can install, and this will allow you to work around that.

Tutorials

Individual and Population Simulations

vignette(package="ubiquity", topic="Simulation")

If you are just getting started, the simulation tutorial and the accompanying vignette are a good place to go first. This tutorial will provide you with an introduction to the ubiquity language, the creation of simulation templates, and how to customize those templates to perform both individual and population simulations. Just open up the vignette and follow along in the tutorial.

Watch on Vimeo

 

Naive-pooled parameter estimation

vignette(package="ubiquity", topic="Estimation")

Once you have your model running and the simulations look good, the next step is to estimate parameters. With ubiquity you can fit some or all of your parameters to experimental data. You can make use of both local and global optimizers in R and the integrated reporting allows you write your results directly to PowerPoint or Word.

Watch on Vimeo

 

Model Deployment

vignette(package="ubiquity", topic="Deployment")

After you’ve created your model it’s time to make it more useful. You can do this by making it easier for others run your model and analyze its outputs. The “ShinyApp” template will create the files you need to run simulations interactively at the team level or deploy your model on a Shiny server. The deployment vignette and tutorial cover both how to use the base Shiny app and also how to customize it for your own purposes.

Watch on Vimeo