Spot.Price.Simulate: Spot.Price.Simulate

Description Usage Arguments Details Value References Examples

View source: R/Simulations.R

Description

Simulate risk-neutral price paths of an an N-factor commodity pricing model through Monte Carlo Simulation.

Usage

1
2
3
4
5
6
7
8
9
Spot.Price.Simulate(
  X.0,
  parameters,
  t = 1,
  dt = 1,
  n = 2,
  antithetic = TRUE,
  verbose = FALSE
)

Arguments

X.0

Initial values of the state vector.

parameters

A named vector of parameter values of a specified N-factor model. Function CPM.Parameters is recommended.

t

the number of years to simulate

dt

discrete time step of simulation

n

total number of simulations

antithetic

logical. Should antithetic price paths be simulated?

verbose

logical. Should simulated state variables be output? see returns

Details

\loadmathjax

The Spot.Price.Simulate function is able to quickly simulate a large number of risk-neutral price paths of a commodity following the N-factor model. Simulating risk-neutral price paths of a commodity under an N-factor model through Monte Carlo simulations allows for the valuation of commodity related investments and derivatives, such as American Options and Real Options through dynamic programming methods. The Spot.Price.Simulate function quickly and efficiently simulates an N-factor model over a specified number of years, simulating antithetic price paths as a simple variance reduction technique. The Spot.Price.Simulate function uses the mvrnorm function from the MASS package to draw from a multivariate normal distribution for the simulation shocks.

The N-factor model stochastic differential equation is given by:

Brownian Motion processes (ie. factor one when GBM = T) are simulated using the following solution:

\mjdeqn

x_1,t+1 = x_1,t + \mu^*\Delta t + \sigma_1 \Delta t Z_t+1x[1,t+1] = x[1,t] + mu^* * Delta t + sigma[1] * Delta t * Z[t+1]

Where \mjeqn\Delta tDelta t is the discrete time step, \mjeqn\mu^*mu^* is the risk-neutral growth rate and \mjeqn\sigma_1sigma[1] is the instantaneous volatility. \mjeqnZ_tZ[t] represents the independent standard normal at time \mjeqntt.

Ornstein-Uhlenbeck Processes are simulated using the following solution:

\mjdeqn

x_i,t = x_i,0e^-\kappa_it-\frac\lambda_i\kappa_i(1-e^-\kappa_it)+\int_0^t\sigma_ie^\kappa_isdW_sx[i,t] = x[i,0] * e^(-kappa[i] * t) - lambda[i]/kappa[i] * (1 - e^(-kappa[i] * t)) + int_0^t (sigma[i] * e^(kappa[i] * s) dW[s])

Where a numerical solution is obtained by numerically discretising and approximating the integral term using the Euler-Maruyama integration scheme: \mjdeqn\int_0^t\sigma_ie^\kappa_isdW_s = \sum_j=0^t \sigma_ie^\kappa_ijdW_sint_0^t ( sigma[i] e^(kappa[i] * s) dw[s])

Value

Spot.Price.Simulate returns a list when verbose = T and a matrix of simulated price paths when verbose = F. The returned objects in the list are:

Prices A matrix of simulated price paths. Each column represents one simulated price path and each row represents one simulated observation.

Factors A matrix of simulated state variables for each factor is returned when verbose = T. The number of factors returned corresponds to the number of factors in the specified N-factor model.

References

Schwartz, E. S., and J. E. Smith, (2000). Short-Term Variations and Long-Term Dynamics in Commodity Prices. Manage. Sci., 46, 893-911.

Cortazar, G., and L. Naranjo, (2006). An N-factor Gaussian model of oil futures prices. Journal of Futures Markets: Futures, Options, and Other Derivative Products, 26(3), 243-268.

Examples

 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
# Example 1
###Simulate a Geometric Brownian Motion (GBM) process:
## Starting price of 20, with a growth of 5% p.a. and
## volatility of 20% p.a.
Simulated.Spot.Prices <- Spot.Price.Simulate(
 X.0 = log(20),
 parameters = c(mu_star = (0.05 - 0.5 * 0.2^2), sigma_1 = 0.2),
 t = 1,
 dt = 1/12,
 n = 1e3)

# Example 2
###Simulate future spot price paths under Risk-Neutrality and under the
###Schwartz - Smith two factor model:

##Step 1 - Run the Kalman Filter for the Two-Factor Oil Model:
Schwartz.Smith.Oil <- CPM.Kalman.filter(parameter.values = SS.Oil$Two.Factor,
                                      parameters = names(SS.Oil$Two.Factor),
                                      log.futures = log(SS.Oil$Stitched.Futures),
                                      dt = SS.Oil$dt,
                                      TTM = SS.Oil$Stitched.TTM,
                                      verbose = TRUE)

#Step 2 - Simulate spot prices:
##100 antithetic simulations of one year of monthly observations
Simulated.Spot.Prices <- Spot.Price.Simulate(
 X.0 = Schwartz.Smith.Oil$X.t,
 parameters = SS.Oil$Two.Factor,
 t = 1,
 dt = 1/12,
 n = 1e3,
 antithetic = TRUE,
 verbose = TRUE)

##Not Run - Plot Price Paths:
# matplot(seq(0,1,1/12), Simulated.Spot.Prices$Prices, type = 'l')

##Not Run - Plot Antithetic Price Pairs:
# matplot(seq(0,1,1/12), Simulated.Spot.Prices$Prices[,1:2], type = 'l')

##Not Run - Plot 95% Prediction interval:
# Prediction.interval <- rbind.data.frame(apply(Simulated.Spot.Prices$Prices, 1,
#                        FUN = function(x) stats::quantile(x, probs = c(0.025, 0.975))),
#                        Mean = rowMeans(Simulated.Spot.Prices$Prices))
# matplot(seq(0,1,1/12), t(Prediction.interval), type = 'l', col = c(2,2,1),
# lwd = 2, lty = c(2,2,1))

TomAspinall/TSE documentation built on Jan. 7, 2021, 7:43 p.m.