Displaying 2 results from an estimated 2 matches for "phiheston".
2011 Aug 26
3
How to vectorize a function to handle two vectors
...ong). However, the function uses k[1] for
t 1 to 4, and thereby returns 16 different values instead of just 4.
Can anyone tell me how to do this - I know the answer is simple, but I dont
understand how
Thank you for your time
Kinds Rikke
#------ Characteristic function of the Heston model -----#
phiHeston <- function(parameters)
{
lambda <- parameters[1];
rho <- parameters[2];
eta <- parameters[3];
theta <- parameters[4];
v0 <- parameters[5];
function(u, t)
{
alpha <- -u*u/2 - 1i*u/2;
beta <- lambda - rho*eta*1i*u;
gamma <- eta^2/2;
d <...
2011 Aug 18
3
Error message: object of type 'closure' is not subsettable
...d <- function(u) {Re(exp(-1i*u*k)*phi(u - 1i/2, t)/(u^2 + 1/4))}
res <- S0*exp(-q*t) -
exp(k/2)/pi*integrate(integrand,lower=0,upper=Inf)$value
return(res)
}
Price_callVec <- function(phi, k, t)
{
mapply(Price_call, phi, k, t)
}
# The characteric formula for the Heston model (Eq. XX)
phiHeston <- function(kappa, rho, eta, theta, v0)
{
lambda <- - kappa
function(u, t)
{
alpha <- -u*u/2 - 1i*u/2
beta <- lambda - rho*eta*1i*u
gamma <- eta^2/2
d <- sqrt(beta*beta - 4*alpha*gamma)
rplus <- (beta + d)/(eta^2)
rminus <- (beta - d)/(eta^2)
g &...