Learn R Programming

schwartz97 (version 0.0.6)

distribution-state: Schwartz two-factor Model: Distribution of the State Variables

Description

Density, distribution function and quantile function of the state variables. The state variables are the commodity spot price s and the spot convenience yield delta. The commodity log spot price and the convenience yield follow a bivariate normal distribution.

Usage

"dstate"(x, time = 1, s0 = 50, delta0 = 0, mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5, rho = 0.75, ...)
"dstate"(x, time = 1, s0, ...)
"pstate"(lower, upper, time = 1, s0 = 50, delta0 = 0, mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5, rho = 0.75, ...)
"pstate"(lower, upper, time = 1, s0, ...)
"qstate"(p, time = 1, s0 = 50, delta0 = 0, mu = 0.1, sigmaS = 0.3, kappa = 1, alpha = 0, sigmaE = 0.5, rho = 0.75, tail = "lower.tail", ...)
"qstate"(p, time = 1, s0, tail = "lower.tail", ...)

Arguments

x
Vector or matrix of quantiles. If x is a matrix, each row is taken to be a quantile.
time
Time at which the quantity is computed (relative to time zero).
p
Probability, a scalar.
lower
The vector of lower limits of length 2. Note that first component stands for lower limit of the commodity spot price rather than the log-price.
upper
The vector of upper limits of length 2. Note that first component stands for the upper limit of the commodity spot price rather than the log-price.
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.
tail
See qmvnorm of package mvtnorm.
...
Further arguments to be passed to methods of package mvtnorm.

Value

dstate and pstate return a numeric, qstate returns the output of qmvnorm as a list.

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, and qmvnorm of the package mvtnorm.

See Also

schwartz2f-class description, rstate and simstate for random number generation, constructors schwartz2f and fit.schwartz2f.

Examples

Run this code
# ## Create a "schwartz2f"-object
# model <- schwartz2f()
# 
# ## Probability
# pstate(lower = c(0, -Inf), upper = c(45, 0.01), time = 1, model)
# 
# ## Density
# dstate(x = c(50, 0.03), time = 2, model) 
# dstate(x = rbind(c(50, 0.03), c(50, 0.1)), time = 2, model) # x is a matrix 
# 
# ## Quantile
# qstate(p = 0.5, s0 = model)
# 
# ## Generate random numbers
# object <- schwartz2f(alpha = 0.05)
# samples <- rstate(1000, time = 2, object)
# ## ...and plot histograms
# par(mfrow = c(2, 1))
# hist(samples[,1])
# abline(v = mean(object, time = 2)[1], col = "red")
# hist(samples[,2])
# abline(v = mean(object, time = 2)[2], col = "red")

Run the code above in your browser using DataLab