Как оценить параметры Black-schole или GBM в R - PullRequest
0 голосов
/ 30 марта 2019

Как я могу оценить дрейф и волатильность GBM или BROWNIAN MOTION PROCESS в коде R? в Python есть код, но в R

нет ничего

Ответы [ 2 ]

1 голос
/ 30 марта 2019

С пакетом Sim.DiffProc, пример:

library(Sim.DiffProc)

# simulate a trajectory of a GBM
# (theta: drift factor, sigma: volatility)
set.seed(666)
traj <- GBM(N=10000, t0=0, T=1, x0=1, theta=4, sigma=2)

# fit the parameters
fx <- expression( theta[1]*x ) ## drift coefficient of model (theta1 = theta)
gx <- expression( theta[2]*x ) ## diffusion coefficient of model (theta2 = sigma)
fit <- fitsde(data = traj, drift = fx, diffusion = gx, 
              start = list(theta1=3, theta2=3), 
              lower = c(0, 0), control = list(maxit=1000))
coef(fit) ## estimates
#   theta1   theta2 
# 7.042467 2.000404 
confint(fit) ## confidence intervals
#           2.5 %    97.5 %
# theta1 3.121749 10.963185
# theta2 1.972680  2.028127
0 голосов
/ 20 мая 2019

наконец я нашел свой ответ:

# calculating log returns
returns <- diff(log(price))
# calculate mu (drift)
mu = mean(returns)
# calculate sigma
sigma = sd(returns)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...