[R] Problems with integrate
tolga at coubros.com
Sat Dec 10 18:22:02 CET 2005
Having a weird problem with the integrate function.
I have a function which calculates a loss density: I'd like to integrate
it to get the distribution.
The loss density function is:
# the second derivative of the PDF
# p is the default probability of the pool at which we are evaluating
# Beta is the correlation with the market factor as a function of K
# R is the recovery rate
C=qnorm(p) # default threshold for the pool
Beta needs to be passed in as a function:
Now, when I try out lossdensity, it works fine:
I defined lossdistribution as:
But this gives a weird error:
Error in "[<-"(`*tmp*`, k, i, value = c(4.29850518211428, 0, 0, 0, 0, :
number of items to replace is not a multiple of replacement length
What's interesting is, if I use the area function from library(MASS), it
I could just go ahead and use that, but would like to understand why
integrate is not working.
Thanks in advance,
More information about the R-help