This lecture as: slideshow (html), Rmarkdown (Rmd), notes (pdf).
The entire module: notes (pdf).
Re-run all the examples from the lecture and be sure to understand the method and the code.
Expand Example 3 (Bivariate reliability problem) from the lecture.
Go back to using normally distributed B and C. In the original example they were independent. Now we want to investigate if they are dependent, e.g. to account for inflation. We use the package mvtnorm
to simulate from a bivariate normal distribution. This distribution is parameterised by a variances and covariance.
Recall what variance, covariance and correlation are.
Understand the code below. For example, read it and try it out, e.g. Sigma(-1)
, Sigma(0)
and Sigma(1)
:
c(100, 50)
mu <- function(corr) {
Sigma <- 10^2
var <-# corBC = covBC / sqrt(varB*varC)
# <=>
# covBC = corBC * sqrt(varB*varC)
corr*sqrt(var*var)
cov <-matrix(c(var, cov, cov, var), nrow = 2)
}library(mvtnorm)
set.seed(48)
rmvnorm(n = 1, mean = mu, sigma = Sigma(1))
x <- x
Draw random samples for correlation of -1, -0.5, 0, 0.5 and 1 and illustrate these (in individual figures).
Now, investigate the sensitivity of the correlation on P(g(B, C) < 0) for correlation values ranging from -0.95 to 0.95. Remember figure(s).
Expand Example 4 (Wholesales offer) from the lecture.
Expand Example 3 (Bivariate reliability problem) from the lecture
Use Gamma distributed variables for budget and expected costs (read about the gamma distribution e.g. [WMMY] Sec. 6.6, note that [WMMY] uses α and β to denote shape and scale).
Find parameter values of shape and scale that approximately resembles the corresponding normal distribution.
Do the Monte Carlo approximation of P(g(B, C) < 0). Note that rgamma()
is used to sample from a gamma distribution. Is the probability similar or different from when using the normal distribution?
Draw a scatterplot and mark the points where g(B, C) < 0.