Learn R Programming

PRA: Project Risk Analysis in R

Key features:

  • The Second Moment Method
  • Monte Carlo Simulation
  • Contingency Analysis
  • Sensitivity Analysis
  • Earned Value Management
  • Learning Curves
  • Design Structure Matrices
  • And more!

Installation

To install the release verion of PRA, use:

install_packages('PRA')

You can install the development version of PRA like so:

devtools::install_github('paulgovan/PRA')

Usage

Here is a basic example which shows you how to solve a common problem using Monte Carlo Simulation.

First, load the package:

library(PRA)

Next, set the number of simulations and describe probability distributions for 3 work packages:

num_simulations <- 10000
task_distributions <- list(
  list(type = "normal", mean = 10, sd = 2),  # Task A: Normal distribution
  list(type = "triangular", a = 5, b = 10, c = 15),  # Task B: Triangular distribution
  list(type = "uniform", min = 8, max = 12)  # Task C: Uniform distribution
)

Then, set the correlation matrix between the 3 work packages:

correlation_matrix <- matrix(c(
  1, 0.5, 0.3,
  0.5, 1, 0.4,
  0.3, 0.4, 1
), nrow = 3, byrow = TRUE)

Finally, run the simulation using the mcs function:

results <- mcs(num_simulations, task_distributions, correlation_matrix)

To calculate the mean of the total duration:

cat("Mean Total Duration:", results$total_mean, "\n")
#> Mean Total Duration: 38.57388

To calculate the variance of the total duration:

cat("Variance of Total Duration:", results$total_variance, "\n")
#> Variance of Total Duration: 19.65191

To build a histogram of the total duration:

hist(results$total_distribution, breaks = 50, main = "Distribution of Total Project Duration", 
     xlab = "Total Duration", col = "skyblue", border = "white")

More Resources

Much of this package is based on the book Data Analysis for Engineering and Project Risk Managment by Ivan Damnjanovic and Ken Reinschmidt and comes highly recommended.

Code of Conduct

Please note that the PRA project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('PRA')

Monthly Downloads

142

Version

0.3.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Paul Govan

Last Published

August 20th, 2024

Functions in PRA (0.3.0)

sensitivity

Sensitivity Analysis.
smm

Second Moment Analysis.
parent_dsm

Resource-based 'Parent' Design Structure Matrix (DSM).
mcs

Monte Carlo Simulation.
grandparent_dsm

Risk-based 'Grandparent' Design Structure Matrix (DSM).
fit_sigmoidal

Fit a Sigmoidal Model.
spi

Schedule Performance Index (SPI).
sv

Schedule Variance (SV).
cpi

Cost Performance Index (CPI).
cor_matrix

Generate Correlation Matrix.
ac

Actual Cost (AC).
ev

Earned Value (EV).
cv

Cost Variance (CV).
contingency

Contingency Calculation.
predict_sigmoidal

Predict a Sigmoidal Function.
pv

Planned Value (PV).