How to Create Rgogo Modeling Project
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.
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.
This subfolder contains all the R script files that implement variaous model components such as products, assumptions, methodologies, etc.
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
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
This folder contains R scripts for running a model. Note the distinction between
R subfolder and
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.
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
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
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:
In RStudio menu, click File > New Project...
A New Project Wizard dialog box appears. In the dialog box, click New Directory.
In Project Type dialog box, click R Package.
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.
Method 2: Using Rgogo Command (Recommended)
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:
1library(Rgogo) 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.
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:
Create a project.
Implement model components, including products, assumptions, methodology (actuarial models), etc.
Deploy model components
If you encounter any programming errors, go back to step 2 and repeat the process.
- Run model
If you encounter any programming errors or incorrect results, go back to step 2 and repeat the process.