Displaying 2 results from an estimated 2 matches for "hestoncall".
2012 Apr 26
2
ErrError in f(x, ...) : object 'g.' not found
...language for me so sorry in advance if this error is to basic
for posting. I have tried the R manual and search online for quite a few, if
anyone could help i would be very thankful.
Here is my code.
kappa = 1.1
theta = 0.1
sigma = 0.4
rho = -0.6
v0 = 0.2
r = 0.05
T = 0.5
s0 = 1
K = 0.5
type = 1
Hestoncall = function(kappa,theta,sigma,rho,v0,r,T,s0,K,type)
{
u = 0.5
b = kappa-rho*sigma
a = kappa*theta
x = log(s0)
Hestf = function(phi)
{
d = sqrt((b-rho*sigma*phi*complex(1,0,1)-b )^2-sigma^2*(2*u*phi^2))
g =
(b-rho*sigma*phi*complex(1,0,1)+d)/(b-rho*sigma*p...
2011 Aug 18
3
Error message: object of type 'closure' is not subsettable
...;- (beta + d)/(eta^2)
rminus <- (beta - d)/(eta^2)
g <- rminus / rplus
D <- rminus * (1 - exp(-d*t))/ (1 - g*exp(-d*t))
C <- lambda* (rminus * t - 2/eta^2 * log( (1 - g*exp(-(d*t)))/(1 - g)) )
return(exp(C*theta + D*v0))
}
}
## Calculating the Heston model price with fourier
HestonCall<-function(k,t)
{
res<-Price_callVec(phiHeston(kappa, rho, eta, theta, v0),k,t)
return(res)
}
##### Vectorizing the function to handle vectors of strikes and maturities
HestonCallVec <- function(k,t)
{
mapply (HestonCall, k, t)
}
lb <- c(0, -0.9, 0, 0, 0)
ub <- c(100, 0.9, 0.5, 1, 1...