sim_schwartz | R Documentation |
Simulate a Schwartz process using Rcpp.
sim_schwartz(prici, priceq, theta, innov)
prici |
The initial price. |
priceq |
The equilibrium price. |
theta |
The strength of mean reversion. |
innov |
A single-column matrix of innovations (random numbers). |
The function sim_schwartz()
simulates a Schwartz process
using fast Rcpp C++
code.
The Schwartz process is the exponential of the Ornstein-Uhlenbeck process, and similar comments apply to it. The prices are calculated as the exponentially compounded returns, so they are never negative. The log prices can be obtained by taking the logarithm of the prices.
The function sim_schwartz()
simulates the percentage returns as
equal to the difference between the equilibrium price \mu
minus the
latest price p_{i-1}
, times the mean reversion parameter
\theta
, plus a random normal innovation.
The function sim_schwartz()
returns a single-column matrix
representing the time series of simulated prices.
A single-column matrix of simulated prices, with the same
number of rows as the argument innov
.
## Not run:
# Define the Schwartz model parameters
prici <- 1.0
priceq <- 2.0
thetav <- 0.01
innov <- matrix(rnorm(1e3, sd=0.01))
# Simulate Schwartz process using Rcpp
prices <- HighFreq::sim_schwartz(prici=prici, priceq=priceq, theta=thetav, innov=innov)
plot(prices, t="l", main="Simulated Schwartz Prices", ylab="prices")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.