#### quantsmodelsbottles

##### Active Member

Hi all,

I am working on a model to create a transition matrix for rating transitions of various credit portfolios. I assume a normal prior distribution (standardized for values only between 0 and 1, which is the range of the enumerated credit rating values) of credit transitions given parameters μ and σ, as well as a normal (standardized to be between 0 and 1) prior density over the parameters μ and σ themselves. I know normal isn't the best assumption, but I just want to get a good first order analysis of the data. Anyways, I am following the method described in Chapter 8.3 of The Elements of Statistical Learning (page 268 in the linked pdf). To integrate over the parameter space and update the prior for the transition density function of each rating, I have to compute the integral Pr(z_new|Z) = ∫ Pr(z_new|θ) · Pr(θ|Z) dθ where θ = (μ,σ). I am doing this using scipy.integrate.dblquad; however, it takes astronomically long to update given one z, let along many observations Z. Does anyone know of a way to speed it up? I am attempting to use Cython without much luck. Should I discretize the parameter space θ along with its associated probability density, by using a discrete distribution such that P(θ) ~ O(e^(|θ-θ_mean|^2))?

I am working on a model to create a transition matrix for rating transitions of various credit portfolios. I assume a normal prior distribution (standardized for values only between 0 and 1, which is the range of the enumerated credit rating values) of credit transitions given parameters μ and σ, as well as a normal (standardized to be between 0 and 1) prior density over the parameters μ and σ themselves. I know normal isn't the best assumption, but I just want to get a good first order analysis of the data. Anyways, I am following the method described in Chapter 8.3 of The Elements of Statistical Learning (page 268 in the linked pdf). To integrate over the parameter space and update the prior for the transition density function of each rating, I have to compute the integral Pr(z_new|Z) = ∫ Pr(z_new|θ) · Pr(θ|Z) dθ where θ = (μ,σ). I am doing this using scipy.integrate.dblquad; however, it takes astronomically long to update given one z, let along many observations Z. Does anyone know of a way to speed it up? I am attempting to use Cython without much luck. Should I discretize the parameter space θ along with its associated probability density, by using a discrete distribution such that P(θ) ~ O(e^(|θ-θ_mean|^2))?

Last edited: