Last data update: 2014.03.03

R: Schwartz two-factor Model: Sampling from the State Variables
rand-stateR Documentation

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


## S4 method for signature 'ANY,ANY,numeric'
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")

## S4 method for signature 'ANY,ANY,schwartz2f'
rstate(n, time = 1, s0, method = "chol")

## S4 method for signature 'ANY,ANY,numeric'
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")

## S4 method for signature 'ANY,ANY,schwartz2f'
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.

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.

Value

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

Author(s)

Philipp Erb, David Luethi, Juri Hinz

See Also

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

Examples

# ## 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")

Results