On Aug 26, 2011, at 4:52 PM, Newbie wrote:

Thank you for the quick response! I think you are on the right track - but is there any way of "calling" (is that the word for it) the function price_call
in the mapply, so that this price_call function is changed to handle
vectors. I believe that this should, in theory if it is correct, make the
result be values.

I have part of a code that works for only one vector. So maybe some where in
the line of:
callOptionkVec <- function(phi, kVec, t)
{
        sapply(kVec,function(k) {callOption(phi,k,t)})
}
is what I need to do. Do you have any ideas on how to do this?

What about this:

> mapply(Price_call, kV, tV, MoreArgs=list(phi=phiHeston(subHeston)))
[1]  0.000000001877372 -0.000000632320728  0.000000626031829
[4]  0.000000058381615



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-vectorize-a-function-to-handle-two-vectors-tp3771705p3771902.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to