How to Create Rgogo Modeling Project

Share on:


This article explains what an Rgogo modeling project is and how to create a new project.

Modeling Project Structure

A modeling project implemented with Rgogo framework is essentially an R project for creating a package. The structure of a project is represented by a folder in the file system of your computer. The name of the folder is the name of the project.

An Rgogo modeling project folder typically comprises the following files and subfolders:


This file contains basic information about the project package.

  • NAMESPACE file

This file allows you to specify which variables should be imported from other packages for your development, and which varaiables should be exported and make available to users of your project package.

  • R subfolder

This subfolder contains all the R script files that implement variaous model components such as products, assumptions, methodologies, etc.

  • data subfolder

This subfolder contains the deployed modeling components. In an Rgogo modeling exercise, a modeler typically writes codes to implement modeling components and save them under R subfolder. Before running the model, the modeler needs to deploy the implemented components and save them in R data file (.rda) format. These .rda files are stored under data subfolder.

  • data-raw subfolder

This subfolder contains any non-R files that are needed when you run a model. For example, a valuation project requires reading seriatim policy data from an Excel file. The Excel file will be stored under data-raw subfolder.

  • batch subfolder

This folder contains R scripts for running a model. Note the distinction between R subfolder and batch subfolder. R subfolder contains script files that implement model components, while batch subfolder contains script files that put all the implemented components together and run the model.

  • db subfolder

If a modeling exercise involves a large amount of data input/output, you likely need a database tool to store and access the information efficiently. In this case, the database file is stored under db subfolder.

  • export subfolder

In case the results from running a model are exported to an external file (other than writing to database), such a file can be stored in export subfolder. For example, your valuation job summarizes reserve calculation results and export the summary to an Excel file, this Excel file can be saved in export subfolder.

Creating a New Project

Method 1: Using RStudio Menu

It is straightforward for RStudio users to create a new project using the "New Project" function in RStudio menu. To do so:

  1. In RStudio menu, click File > New Project...

  2. A New Project Wizard dialog box appears. In the dialog box, click New Directory.

  3. In Project Type dialog box, click R Package.

  4. In Create R Package dialog box, enter the name of your modeling project as Package name, and click Browse... button to select the location where you would like to save your project. Click Create Project button.

Once you complete the above steps, RStudio will automatically create a standard RStudio empty project and load it into the session. However, you may want to do a few extra steps manually:

  • Delete hello.R file under R subfolder.
  • Delete man subfolder.
  • Create subfolders for Rgogo modeling project such as data, batch, data-raw, db, export, etc.

Rgogo provides a simple way to create a new modeling project. This is the recommended approach.

To do so, type the following command in RStudio console:

2CreateProject("MyNewProject", "~/RProjects/")

There are two arguments in the above CreateProject function. The first argument is a string that represents the name of your new project. The second argument is also a string that is the location where the project folder will be created. The value of the above two arguments are for illustration purpose only. You should change them according to your individual needs.

Once the CreateProject is executed successfully, open the newly created project using RStudio menu by clicking File > Open Project..., and select the folder of the new project that you have specified.

Modeling Project Workflow

A typical modeling project workflow involves the following steps:

  1. Create a project.

  2. Implement model components, including products, assumptions, methodology (actuarial models), etc.

  3. Deploy model components

If you encounter any programming errors, go back to step 2 and repeat the process.

  1. Run model

If you encounter any programming errors or incorrect results, go back to step 2 and repeat the process.