Displaying 1 result from an estimated 1 matches for "hestoncallvec2".
Did you mean:
hestoncallvec
2011 Aug 26
3
How to vectorize a function to handle two vectors
...lt;- c(0.9,1,1.2,1.3)
tV <- c(0.1,0.4,0.5, 1)
HestonCallVec <- function(phi, kVec, t)
{
sapply(kVec, function(k){Price_call(phi, k, t)})
}
HestonCallVec(phiHeston(subHeston), kV, 1)
subHeston <- c(0.6067,-0.7571,0.2928,0.0707,0.0654);
kV <- c(0.9,1,1.2,1.3)
tV <- c(0.1,0.4,0.5, 1)
HestonCallVec2 <- function(phi, kVec, tVec)
{
sapply(tVec, function(t){HestonCallVec(phi, kVec, t)})
}
HestonCallVec2(phiHeston(subHeston), kV, tV)
# This should give 4 values
This is what I tried for the mapply function, which returns a list, instead
of values.
HestonCallVec <- function(phi, kVec, t)
{
m...