Hi everybody,

Im currently a student in Financial Engineering and one of my subject is called "Rating". During the class, we had a set of data: 4000 companies, 1 dummy variable (representing the solvability of the company at the end of the period) and 6 explicative variables for each company. We tried thanks to the logit regression and the newton raphson method to estimate the probability of default.

Now i am trying to guess what we ll have at the exam and after reading a lot on the topic, I think we could be asked to estimate the same probability of default with the probit regression!

How could i compute such a probit function?

For example, if it might help you, the logit function is as follow:

Function Logit(y As Range, xraw As Range)

'compter les variables
Dim i As Long, j As Long, jj As Long

'dimensions des données
Dim K As Long, N As Long
N = y.Rows.Count
K = xraw.Columns.Count + 1

'ajout de vecteur constante si constant=1 nommé xraw=x
Dim x() As Double
ReDim x(1 To N, 1 To K)
For i = 1 To N
    x(i, 1) = 1
    For j = 2 To K
        x(i, j) = xraw(i, j - 1)
    Next j
Next i

'initialisation des vecteurs coeff b et score bx
Dim b() As Double, bx() As Double, ybar As Double
ReDim b(1 To K)
ReDim bx(1 To N)
ybar = Application.WorksheetFunction.Average(y)
b(1) = Log(ybar / (1 - ybar))
For i = 1 To N
    bx(i) = b(1)
Next i

'Definir variables dans  Newton
Dim sens As Double, maxiter As Integer, iter As Integer, change As Double
Dim lambda() As Double, lnL() As Double, dlnL() As Double, hesse() As Double, hinv(), hinvg()
ReDim lambda(1 To N)
sens = 1 * 10 ^ (-11): maxiter = 50
ReDim lnL(1 To maxiter)
change = sens + 1: iter = 1: lnL(1) = 0
'Loop for Newton iteration
Do While Abs(change) > sens And iter < maxiter
    iter = iter + 1
    'M à Zero derivée log likelihood and Hessian
    Erase dlnL, hesse
    ReDim dlnL(1 To K): ReDim hesse(1 To K, 1 To K)
    
'calculer prediction Lambda, gradient dlnl, Hessien hesse, et log vraisembl lnL
For i = 1 To N
lambda(i) = 1 / (1 + Exp(-bx(i)))
    For j = 1 To K
        dlnL(j) = dlnL(j) + (y(i) - lambda(i)) * x(i, j)
            For jj = 1 To K
                hesse(jj, j) = hesse(jj, j) - lambda(i) * (1 - lambda(i)) * x(i, jj) * x(i, j)
            Next jj
    Next j
    lnL(iter) = lnL(iter) + y(i) * Log(1 / (1 + Exp(-bx(i)))) + (1 - y(i)) * Log(1 - 1 / (1 + Exp(-bx(i))))
Next i
    
'calcul de l'inverse du Hessien ( = hinv) et le multiplier avec dlnL
hinv = Application.WorksheetFunction.MInverse(hesse)
hinvg = Application.WorksheetFunction.MMult(dlnL, hinv)
change = lnL(iter) - lnL(iter - 1)

' Si converge, sortie et garder le b avec le hessien estimé
If Abs(change) <= sens Then Exit Do

'appliquer Newton schema pour mise a jour coeff b
For j = 1 To K
    b(j) = b(j) - hinvg(j)
Next j

 'Calcul nouveau score (bx)
    For i = 1 To N
        bx(i) = 0
        For j = 1 To K
            bx(i) = bx(i) + b(j) * x(i, j)
        Next j
    Next i
Loop
Logit = b
End Function

Except changing the lambda, how can we deal with the Log in the end?

THANKS a lot!!! because i think it's really hard...