R/calculatereturns.R
calculatereturns.Rd
Calculate returns or log-returns for multivariate time series
calculatereturns(x, type = c("basic", "log"))
Multivariate time series
Type of return: basic return ("basic") or log-return ("log")
kappa <- 1.5
V0 <- theta <- 0.04
sigma_v <- 0.2
theta1 <- kappa*theta
theta2 <- kappa
eps0 <- simshocks(n = 100, horizon = 5, frequency = "quart")
sim_GBM <- simdiff(n = 100, horizon = 5, frequency = "quart",
model = "GBM",
x0 = 100, theta1 = 0.03, theta2 = 0.1, eps = eps0)
returns <- calculatereturns(sim_GBM)
log_returns <- calculatereturns(sim_GBM, type = "log")
print(identical(returns, log_returns))
#> [1] FALSE
par(mfrow=c(1, 2))
matplot(returns, type = 'l')
matplot(log_returns, type = 'l')