This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(httpuv) | |
library(RColorBrewer) | |
library(twitteR) | |
library(tm) | |
library(wordcloud) | |
library(base64enc) | |
library(devtools) | |
library(ROAuth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is the code for the negative log likelihood function | |
#for the JUmp-difusion model | |
nll_jumps<-function(w) | |
{ | |
mu=w[1] # drift | |
s=(w[2]) # diffsuive vol | |
lam=(w[3]) # jump frequency | |
mu_j=w[4] # jump size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
simulateJump=function(mu_,ss_,lambda_,mu2_,sigma_,TotalTime,delta) | |
{ | |
Sn=0 | |
times <- c(0) | |
while(Sn <= TotalTime) | |
{ | |
n <- length(times) | |
u <- runif(1) | |
expon <- -log(u)/lambda_ | |
Sn <- times[n]+expon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(DEoptim) | |
# Parameters | |
mu_= 0.05 | |
ss_= 0.3 | |
lambda_= 25 | |
mu2_=0.01 | |
sigma_=0.1 | |
TotalTime = 50 | |
delta=1/252 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_moment<-function(s_0,r,TotalTime) | |
{ | |
(s_0*(exp(r*TotalTime)-1))/(r*TotalTime) | |
} | |
second_moment<-function(s_0,r,s,TotalTime) | |
{ | |
part1 = (2*s_0^2)/(r*(r+s^2)*(2*r+s^2)*TotalTime^2) | |
part2 = r*exp((2*r+s^2)*TotalTime)-(2*r+s^2)*exp(r*TotalTime)+r+s^2 |
OlderNewer