Learn R Programming

schwartz97 (version 0.0.6)

rand-state: Schwartz two-factor Model: Sampling from the State Variables

Description

Random number and trajectory generation of the state variables. The state variables are the commodity spot price s0 and the spot convenience yield delta0. The commodity log spot price and the convenience yield follow a bivariate normal distribution.

Usage

"rstate"(n, time = 1, s0 = 50, delta0 = 0, mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5, rho = 0.75, method = "chol")
"rstate"(n, time = 1, s0, method = "chol")
"simstate"(n, time = 1, s0 = 50, delta0 = 0, mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5, rho = 0.75, method = "chol")
"simstate"(n, time = 1, s0, method = "chol")

Arguments

n
Number of observations.
time
at which random numbers of the state variables are drawn (rstate) or horizon of the trajectory (simstate) relative to now.
s0
Either a numeric representing the initial value of the commodity spot price or an object inheriting from class schwartz2f.
delta0
Initial value of the convenience yield.
mu
enters the drift of the commodity spot price.
sigmaS
Diffusion parameter of the spot price-process.
kappa
Speed of mean-reversion of the convenience yield process.
alpha
Mean-level of the convenience yield process.
sigmaE
Diffusion parameter of the convenience yield process.
rho
Correlation coefficient between the Brownian motion driving the spot price and the convenience yield process.
method
See rmvnorm of package mvtnorm.

Value

Samples or trajectories of the commodity spot price and instantaneous spot convenience yield as matrix.

Details

The model and its parameters are described in the Details section of the schwartz2f-class documentation and in the package vignette Technical Document.

The above methods rely on the functions pmvnorm, dmvnorm, qmvnorm and rmvnorm of the package mvtnorm.

See Also

schwartz2f-class description. d/p/q/state for the density, distribution, and quantile function of the state variables.

Examples

Run this code
# ## Create a "schwartz2f"-object
# model <- schwartz2f()
# 
# ## and sample from its distribution at time = 2.5.
# sim <- rstate(n = 1000, s0 = model, time = 2.5)
# par(mfrow = c(1, 2))
# hist(sim[,1], main = "Distribution of Spot Price")
# hist(sim[,2], main = "Distribution of Convenience Yield")
# 
# 
# ## Create a trajectory over a 6 years horizon sampled on a weekly basis.
# trajectory <- simstate(6 * 52, time = 6, s0 = model)
# par(mfrow = c(1, 2))
# plot(trajectory[,1], main = "Spot Price", type = "l")
# plot(trajectory[,2], main = "Convenience Yield", type = "l")

Run the code above in your browser using DataLab