-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
117 lines (84 loc) · 3.25 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
## PRA: Project Risk Analysis in R
![](https://github.com/paulgovan/PRA/blob/main/inst/logo.png?raw=true){width=25%}
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/PRA)](https://CRAN.R-project.org/package=PRA)
[![CRAN checks](https://badges.cranchecks.info/summary/PRA.svg)](https://cran.r-project.org/web/checks/check_results_PRA.html)
[![](http://cranlogs.r-pkg.org/badges/grand-total/PRA)](https://cran.r-project.org/package=PRA)
[![](http://cranlogs.r-pkg.org/badges/last-month/PRA)](https://cran.r-project.org/package=PRA)
[![](https://img.shields.io/badge/doi-10.32614/CRAN.package.PRA-green.svg)](https://doi.org/10.32614/CRAN.package.PRA)
<!-- badges: end -->
## 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:
``` r
install_packages('PRA')
```
You can install the development version of PRA like so:
``` r
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:
``` {r}
library(PRA)
```
Next, set the number of simulations and describe probability distributions for 3 work packages:
```{r}
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:
```{r}
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:
```{r}
results <- mcs(num_simulations, task_distributions, correlation_matrix)
```
To calculate the mean of the total duration:
```{r}
cat("Mean Total Duration:", results$total_mean, "\n")
```
To calculate the variance of the total duration:
```{r}
cat("Variance of Total Duration:", results$total_variance, "\n")
```
To build a histogram of the total duration:
```{r}
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](https://doi.org/10.1007/978-3-030-14251-3) 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](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.