-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a69aae
Showing
45 changed files
with
2,060 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Package: PRA | ||
Type: Package | ||
Title: Project Risk Analysis | ||
Version: 0.2.0 | ||
Authors@R: person("Paul", "Govan", email = "paul.govan2@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-1821-8492")) | ||
Description: Data analysis for Project Risk Management via the Second Moment Method, Monte Carlo Simulation, Bayesian methods, Design Structure Matrices, and more. | ||
Imports: mc2d, minpack.lm, stats | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
RoxygenNote: 7.3.1 | ||
URL: https://paulgovan.github.io/PRA/, https://github.com/paulgovan/PRA | ||
BugReports: https://github.com/paulgovan/PRA/issues | ||
Suggests: ggplot2, knitr, rmarkdown, testthat (>= 3.0.0) | ||
VignetteBuilder: knitr | ||
Config/testthat/edition: 3 | ||
NeedsCompilation: no | ||
Packaged: 2024-07-01 19:10:44 UTC; paulgovan | ||
Author: Paul Govan [aut, cre, cph] (<https://orcid.org/0000-0002-1821-8492>) | ||
Maintainer: Paul Govan <paul.govan2@gmail.com> | ||
Repository: CRAN | ||
Date/Publication: 2024-07-02 15:20:05 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2024 | ||
COPYRIGHT HOLDER: PRA authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
f3dfd8bb3a057feee3822f4ad380c5f7 *DESCRIPTION | ||
4879028cc3c07e76839597de80bef7bf *LICENSE | ||
ba62e7de2c235a1e0a3db87ada4e3692 *NAMESPACE | ||
df0eb7833550cb601f115bfb2a1b2c98 *NEWS.md | ||
eda1a5c46983d31d67d39e859b2e9802 *R/contingency.R | ||
e5a18bbe46fd1989e17732860dd6adef *R/dsm.R | ||
acebe937f255b998c843656787585f20 *R/evm.R | ||
eb16018e7e8d7babb3e04ae5dbc50aab *R/mcs.R | ||
4478d5eca920e450b2ccf0e5dc6e231c *R/sensitivity.R | ||
4675f5042987c2eddb170725dd09329f *R/sigmoidal.R | ||
97419e0a7e75901ebfd81ed82563f2d2 *R/smm.R | ||
96b55370eff18dbf4b2f58d67893b4ca *README.md | ||
2fa4c1dcdc8dd0561f9ca13163dd8f69 *build/vignette.rds | ||
49e1af367dbdff6f8995b30457e236b8 *inst/CITATION | ||
f6f32b25d2144349f2eb65d916da76df *inst/doc/SMM.R | ||
edd4482435ba8998d639d9bff89c8955 *inst/doc/SMM.Rmd | ||
4f0f309aafc5cecf51e64b8e3f71cde4 *inst/doc/SMM.html | ||
60534aba5b9539f79defd8b232f8cd0d *inst/hexSticker.R | ||
3ab67df2c4b396a7ea04ee718a84b8f5 *inst/logo.png | ||
bd7f36901f382cf94d27b2fffac0097d *man/ac.Rd | ||
dc3ed6b0a66acd5911787ce046c1ce8e *man/contingency.Rd | ||
54fe8714504d68c54d18ec7e6b9b7140 *man/cpi.Rd | ||
70c47d9e725835986ec200e9bb9a0ad0 *man/cv.Rd | ||
79c99c41519d4a12f00b9068e6242736 *man/ev.Rd | ||
ab3dbdacc7b819c12919c6d53dafb91b *man/figures/README-example-1.png | ||
9b6e489b9820eb1098a7652d0bc3755a *man/fit_sigmoidal.Rd | ||
6ca712db5613fa8594afaeefeed8080c *man/grandparent_dsm.Rd | ||
c9fe3e1ea36b1db504a3233b9d5add4c *man/mcs.Rd | ||
9bdf49bcccbc1d93e85d6674a5370920 *man/parent_dsm.Rd | ||
3bddca46f0df9cae0092cd66e334044c *man/predict_sigmoidal.Rd | ||
d6fb73346f53028bc0a9b99a9f66c37b *man/pv.Rd | ||
66ff79a6638210b02111254d24d68052 *man/sensitivity.Rd | ||
5264f9c1a81d9461604fe0a8b229ba29 *man/smm.Rd | ||
74b5bfcc80444580165c8cb344fb395c *man/spi.Rd | ||
543e2ca89227e7b28e484a6eb1cccebd *man/sv.Rd | ||
75aeed517c63e50ccc1665a72fea8ecc *tests/testthat.R | ||
e38bc5411ad3b24faa419ae346b3614d *tests/testthat/test-contingency.R | ||
5f01ee28a2f63e2850d214687f404fac *tests/testthat/test-dsm.R | ||
6964ef21a2c874fea8c417cd60ac0d31 *tests/testthat/test-evm.R | ||
99f3786dcd8b1ed7090659ef248146ed *tests/testthat/test-mcs.R | ||
ee6d8b40b7c481ae4ec72d10b1b85481 *tests/testthat/test-sensitivity.R | ||
516d45ab0d367978615d811c241a491c *tests/testthat/test-sigmoidal.R | ||
9ecf04e602675a86e2760007cb763d76 *tests/testthat/test-smm.R | ||
edd4482435ba8998d639d9bff89c8955 *vignettes/SMM.Rmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(ac) | ||
export(contingency) | ||
export(cpi) | ||
export(cv) | ||
export(ev) | ||
export(fit_sigmoidal) | ||
export(grandparent_dsm) | ||
export(mcs) | ||
export(parent_dsm) | ||
export(predict_sigmoidal) | ||
export(pv) | ||
export(sensitivity) | ||
export(smm) | ||
export(spi) | ||
export(sv) | ||
import(mc2d) | ||
import(minpack.lm) | ||
import(stats) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# PRA 0.2.0 | ||
|
||
# PRA 0.1.0 | ||
|
||
* Initial CRAN submission. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#' Contingency Calculation. | ||
#' | ||
#' @param sims List of results from a Monte Carlo simulation. | ||
#' @param phigh Percentile level for contingency calculation. | ||
#' @param pbase Base level for contingency calculation. | ||
#' @return The function returns the value of calculated contingency. | ||
#' @examples | ||
#' num_sims <- 10000 | ||
#' task_dists <- 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 | ||
#' ) | ||
#' cor_mat <- matrix(c( | ||
#' 1, 0.5, 0.3, | ||
#' 0.5, 1, 0.4, | ||
#' 0.3, 0.4, 1 | ||
#' ), nrow = 3, byrow = TRUE) | ||
#' results <- mcs(num_sims, task_dists, cor_mat) | ||
#' contingency <- contingency(results, phigh = 0.95, pbase = 0.50) | ||
#' cat("Contingency based on 95th percentile and 50th percentile:", contingency) | ||
#' @export | ||
contingency <- function(sims, phigh = 0.95, pbase = 0.50) { | ||
# Check for valid p-values | ||
if (!is.numeric(phigh) || phigh < 0 || phigh > 1) { | ||
stop("phigh must be between 0 and 1") | ||
} | ||
if (!is.numeric(pbase) || pbase < 0 || phigh > 1) { | ||
stop("pbase must be between 0 and 1") | ||
} | ||
if (phigh < pbase) { | ||
stop("phigh must be greater than pbase.") | ||
} | ||
|
||
# Extract the relevant percentiles from the simulation results | ||
phigh_value <- stats::quantile(sims$total_distribution, probs = phigh) | ||
pbase_value <- stats::quantile(sims$total_distribution, probs = pbase) | ||
|
||
# Calculate the contingency | ||
contingency <- phigh_value - pbase_value | ||
|
||
# Return the contingency value | ||
return(contingency) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#' Resource-based 'Parent' Design Structure Matrix (DSM). | ||
#' | ||
#' @param S Resource-Task Matrix 'S' giving the links (arcs) between resources and tasks. | ||
#' @return The function returns the Resource-based 'Parent' DSM 'P' giving the number | ||
#' of resources shared between each task. | ||
#' @examples | ||
#' s <- matrix(c(1, 1, 0, 0, 1, 0, 0, 1, 1), nrow = 3, ncol = 3) | ||
#' cat("Resource-Task Matrix:\n") | ||
#' print(s) | ||
#' resource_dsm <- parent_dsm(s) | ||
#' cat("\nResource-based 'Parent' DSM:\n") | ||
#' print(resource_dsm) | ||
#' @export | ||
|
||
# Parent DSM function | ||
parent_dsm <- function(S) { | ||
|
||
# Check if the matrix is square | ||
if (ncol(S) != nrow(S)) { | ||
stop("The Resource-Task Matrix must be square.") | ||
} | ||
|
||
# Multiply matrix S by the transpose of R | ||
parent_dsm <- S %*% t(S) | ||
|
||
return(parent_dsm) | ||
} | ||
|
||
|
||
#' Risk-based 'Grandparent' Design Structure Matrix (DSM). | ||
#' | ||
#' @param S Resource-Task Matrix 'S' giving the links (arcs) between resources and tasks. | ||
#' @param R Risk-Resource Matrix 'R' giving the links (arcs) between risks and resources. | ||
#' @return The function returns the Risk-based 'Grandparent' DSM 'G' giving the number | ||
#' of risks shared between each task. | ||
#' @examples | ||
#' S <- matrix(c(1, 1, 0, 0, 1, 0, 0, 1, 1), nrow = 3, ncol = 3) | ||
#' R <- matrix(c(1, 1, 1, 1, 0, 0), nrow = 2, ncol = 3) | ||
#' cat("Resource-Task Matrix:\n") | ||
#' print(S) | ||
#' cat("\nRisk-Resource Matrix:\n") | ||
#' print(R) | ||
#' risk_dsm <- grandparent_dsm(S, R) | ||
#' cat("\nRisk-based 'Grandparent' DSM:\n") | ||
#' print(risk_dsm) | ||
#' @export | ||
|
||
# Grandparent DSM function | ||
grandparent_dsm <- function(S, R) { | ||
|
||
|
||
# Check if matrix S is square | ||
if (ncol(S) != nrow(S)) { | ||
stop("Matrix S must be square.") | ||
} | ||
|
||
# Check if the matrices can be multiplied | ||
if (ncol(S) != ncol(R)) { | ||
stop("Number of columns in the Matrix S must be equal to the number | ||
of columns in Matrix R.") | ||
} | ||
|
||
# Multiply matrix S by the transpose of R | ||
t <- S %*% t(R) | ||
|
||
# Multiply matrix T by the transpose of T | ||
grandparent_dsm <- t %*% t(t) | ||
|
||
return(grandparent_dsm) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#' Planned Value (PV). | ||
#' | ||
#' @param bac Budget at Completion (total planned budget). | ||
#' @param schedule Vector of planned work completion (in terms of percentage) at each time period. | ||
#' @param time_period Current time period. | ||
#' @return The function returns the Planned Value (PV) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' schedule <- c(0.1, 0.2, 0.4, 0.7, 1.0) | ||
#' time_period <- 3 | ||
#' pv <- pv(bac, schedule, time_period) | ||
#' cat("Planned Value (PV):", pv, "\n") | ||
#' @export | ||
pv <- function(bac, schedule, time_period) { | ||
|
||
pv <- bac * schedule[time_period] | ||
return(pv) | ||
} | ||
|
||
#' Earned Value (EV). | ||
#' | ||
#' @param bac Budget at Completion (total planned budget). | ||
#' @param actual_per_complete Actual work completion percentage. | ||
#' @return The function returns the Earned Value (EV) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' actual_per_complete <- 0.35 | ||
#' | ||
#' ev <- ev(bac, actual_per_complete) | ||
#' cat("Earned Value (EV):", ev, "\n") | ||
#' @export | ||
ev <- function(bac, actual_per_complete) { | ||
|
||
ev <- bac * actual_per_complete | ||
return(ev) | ||
} | ||
|
||
#' Actual Cost (AC). | ||
#' | ||
#' @param actual_costs Vector of actual costs incurred at each time period. | ||
#' @param time_period Current time period. | ||
#' @return The function returns the Actual Cost (AC) of work completed. | ||
#' @examples | ||
#' actual_costs <- c(9000, 18000, 36000, 70000, 100000) | ||
#' time_period <- 3 | ||
#' | ||
#' ac <- ac(actual_costs, time_period) | ||
#' cat("Actual Cost (AC):", ac, "\n") | ||
#' @export | ||
ac <- function(actual_costs, time_period) { | ||
|
||
ac <- actual_costs[time_period] | ||
return(ac) | ||
} | ||
|
||
#' Schedule Variance (SV). | ||
#' | ||
#' @param ev Earned Value. | ||
#' @param pv Planned Value. | ||
#' @return The function returns the Schedule Variance (SV) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' schedule <- c(0.1, 0.2, 0.4, 0.7, 1.0) | ||
#' time_period <- 3 | ||
#' pv <- pv(bac, schedule, time_period) | ||
#' actual_per_complete <- 0.35 | ||
#' ev <- ev(bac, actual_per_complete) | ||
#' | ||
#' sv <- sv(ev, pv) | ||
#' cat("Schedule Variance (SV):", sv, "\n") | ||
#' @export | ||
sv <- function(ev, pv) { | ||
|
||
sv <- ev - pv | ||
return(sv) | ||
} | ||
|
||
#' Cost Variance (CV). | ||
#' | ||
#' @param ev Earned Value. | ||
#' @param ac Actual Cost. | ||
#' @return The function returns the Cost Variance (CV) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' actual_per_complete <- 0.35 | ||
#' ev <- ev(bac, actual_per_complete) | ||
#' actual_costs <- c(9000, 18000, 36000, 70000, 100000) | ||
#' time_period <- 3 | ||
#' ac <- ac(actual_costs, time_period) | ||
#' | ||
#' cv <- cv(ev, ac) | ||
#' cat("Cost Variance (CV):", cv, "\n") | ||
#' @export | ||
cv <- function(ev, ac) { | ||
|
||
cv <- ev - ac | ||
return(cv) | ||
} | ||
|
||
#' Schedule Performance Index (SPI). | ||
#' | ||
#' @param ev Earned Value. | ||
#' @param pv Planned Value. | ||
#' @return The function returns the Schedule Performance Index (SPI) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' schedule <- c(0.1, 0.2, 0.4, 0.7, 1.0) | ||
#' time_period <- 3 | ||
#' pv <- pv(bac, schedule, time_period) | ||
#' actual_per_complete <- 0.35 | ||
#' ev <- ev(bac, actual_per_complete) | ||
#' | ||
#' spi <- spi(ev, pv) | ||
#' cat("Schedule Performance Index (SPI):", spi, "\n") | ||
#' @export | ||
spi <- function(ev, pv) { | ||
|
||
spi <- ev / pv | ||
return(spi) | ||
} | ||
|
||
#' Cost Performance Index (CPI). | ||
#' | ||
#' @param ev Earned Value. | ||
#' @param ac Actual Cost. | ||
#' @return The function returns the Cost Performance Index (CPI) of work completed. | ||
#' @examples | ||
#' bac <- 100000 | ||
#' actual_per_complete <- 0.35 | ||
#' ev <- ev(bac, actual_per_complete) | ||
#' actual_costs <- c(9000, 18000, 36000, 70000, 100000) | ||
#' time_period <- 3 | ||
#' ac <- ac(actual_costs, time_period) | ||
#' | ||
#' cpi <- cpi(ev, ac) | ||
#' cat("Cost Performance Index (CPI):", cpi, "\n") | ||
#' @export | ||
cpi <- function(ev, ac) { | ||
|
||
cpi <- ev / ac | ||
return(cpi) | ||
} |
Oops, something went wrong.