The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.
powered by NetLogo
view/download model file: credit_scoring_dimension_and_economic_situation.nlogo
The aim of the model is to analize the sistematic effetcs of the behaviours of banks in the lending activity. It is possible to consider the variation of some global economic variables (the number of firms, the average life of firm, the total amount of loan granted) when the bank penalize or favour the firms on the basis of their dimension.
In order to understand what rules the agents use to create the overall behavior the user can consult the explanation that is inclused in the thesis document.
The model starts when the "setup" button is pressed. In this way the user creates the firms and their links. Subsequently using the "go" button the simulation starts.
The user can change some economic variables, for example costs, revenues, and payments amount, in order to modify the economic situation of firms. It is possible to change the probability of the creation of new firms using the variable prob-new-firm.
Moreover the user can modify the interconnection between firms and its consequences through the variables average-num-links and prob-of-risk-propagation.
Using the chooser economic-stability you can also change the economic situation and you can choose between a stable system and a caotic one.
It is also possible to change some crucial variables related to the lending activity as the loan amount and the maturity. Moreover in order to study the consequences of the behaviours of the banks you can modify the threshold of risk that the bank is allowed to bare (initial-risk-threshold, monitoring-max-risk-threshold and max-mean-cash-level) and the premium associated to the dimension (equal to one no differences, grater than 1 the bank fovour bigger firms, less than 1 favour the smaller firms)
Using the economic_stability variable is possible to move from an stable situation to a caotic and erratic one. In this passage tha user can notice the increase in the number of firms of the simulation.
Modifying the risk thresholds (the initial one and the monitoring one) is also possible to consider changing in the total amount of loan granted and of the percentual number of default per tick.
Moreover increasing or decreasing the premium for large firms (premium-large-firms) is possible to appreciate the variation of the number of the firms of the simulation and in the case of penalization of larger firms the user can notice the collapse of the system and the default of all the agents.
One interesting element concern the prob-of-risk-propagation that means the probability the firms influence each other on the risk side. If the variable equals 1 then every firm influences any other company which is connected with and the system is more stable, while if the variable is close to 0 then the firms tend to be more erratic and more fragile.
The user can try to change the economic situation choosing between stability and instability; the threshold of the risk accepted by the bank, increasing or decreasing the potential set of firms that can access the credit; the premium related to the dimension, favouring or penalizing big firms or small ones; and the loan variables.
The model could be developed working on several elements: the interest rate, in order to improve the lending activity, a better economic structure for the firms, that now are characterized only by cash, and the implementation of the credit scoring model more accurate and that can consider the consequences of the the behaviour of the banks on the economic system.
The library models used as referece are the networks ones (e.g. Small world, Virus on a network, Preferential attachment) and they were used to create the network between firms using links and link structures.
This model was developed by Nicola Giuliano, student of the Faculty of Economics of Turin, during his thesis work under the supervision of Professor Pietro Terna. See http://web.econ.unito.it/terna/tesine for a detailed explanation document and for other student's project works.
;; Advanced credit scoring model turtles-own [ cash risk risk-asim finalproducer? net-payment loan? maturity? life mean-cash perceived-risk] globals [ defaults insolvencies total-loans insolvency-losses repealed-loans defaults-per-tick turtles-per-tick total-num-firms life-firm credit-performance a ] to setup clear-all setup-world setup-turtles setup-links end to setup-world ask patches with [ pxcor = 16 ] [ set pcolor 45 ] end to setup-turtles set-default-shape turtles "square" create-turtles 50 [ set risk-asim 50 set life 0 set maturity? -1 ifelse random 99 < 50 [ set finalproducer? 0 ] [ set finalproducer? 1 + random 5 ] if finalproducer? > 0 [ set size 1.35 set shape "triangle" ] set cash random max-pxcor set risk random max-pycor setxy cash risk ] set total-num-firms 50 end to setup-links ask turtles [ let choice ( n-of (abs int random-normal average-num-links 1 ) ( other turtles with [not in-link-neighbor? myself ] ) ) if choice != nobody [ create-links-to choice ] ] ask links [ set thickness 0.14 ] end to go if not any? turtles [ stop ] turtles-birth links-renovation move-turtles update-plot end to move-turtles set turtles-per-tick count turtles influence-of-position risk-consequences manage-flows collect-info contagion take-credit give-credit time end to time tick ask turtles [ if maturity? >= 0 [ set maturity? maturity? - 1 ] set life life + 1 ] end to influence-of-position ask turtles [ if xcor >= 16 and risk-asim - 3 >= 10 [ set risk-asim risk-asim - 3 ] if xcor < 16 and risk-asim + 3 <= 90 [ set risk-asim risk-asim + 3 ] ] end to risk-consequences if economic_stability = "yes" [ set a 26 ] if economic_stability = "no" [ set a 1 ] ask turtles [ let in-linked-turtles in-link-neighbors let out-linked-turtles out-link-neighbors if random-float 1 < ( 10 ^ (( ycor - 23.42624) / 5.85656108)) / a [ ;; the probability is divided by 26 because one tick means two week and PD are annual set defaults defaults + 1 set defaults-per-tick defaults-per-tick + 1 ask in-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask out-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 1 ] ] set insolvency-losses insolvency-losses + loan? die ] ;; The PD is defined on the baisis of the rating let birthd life / 26 if ( int birthd ) - birthd = 0 [ if random 100 < 92 [ ifelse random 100 < risk-asim [ ifelse risk + 1 <= max-pycor [ set risk risk + 1 ] [ ask in-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask out-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 1 ] ] set insolvency-losses insolvency-losses + loan? default-consequences ] ] [ if risk - 1 >= min-pycor [ set risk risk - 1 ] ] ] ] set ycor risk ] end to manage-flows ask turtles [ if finalproducer? > 0 [ let revenuess ( ( (revenues * finalproducer? ) ) + random-normal 0 2 ) ;; it can be used, instead of count my-in-links, finalproducer? that is a number of liks with the final market if revenuess > 0 [ set cash cash + revenuess ] ] let cost ( ( ( costs * cash * 2.1 ) ) + random-normal 0 2 ) / 20 if cost > 0 [ set cash cash - cost ] if int xcor != cash [ facexy cash ycor forward 0.5 ] ] end to collect-info ask turtles [ let linked-turtles in-link-neighbors ;; client side it checks if you got supplier if any? linked-turtles [ if finalproducer? = 0 [ let payments ( ( payments-amount * 0.1 * count my-in-links ) + random-normal 0 0.5 ) / 2 if payments > 0 [ set net-payment net-payment - payments let payment payments / count my-in-links ask linked-turtles [ set net-payment net-payment + payment ] ] ] ;;] if finalproducer? > 0 [ ;;if random-float 1 < prob-paym [ ;; se metto prob of payment c'è selezione e sopravvivono solo quelle con bassi valori serve 1.3 let payments ( ( revenues * 0.9 * count my-in-links ) + random-normal 0 0.5 ) / 2 if payments > 0 [ set net-payment net-payment - payments let payment payments / count my-in-links ask linked-turtles [ set net-payment net-payment + payment ] ] ] ] ;; ] ] end to contagion ask turtles [ let in-linked-turtles in-link-neighbors ;; client side it checks if it has suppliers if random-float 1 < prob-of-risk-propagation [ if any? in-linked-turtles [ let client-risk risk ask in-linked-turtles [ if client-risk > risk and risk-asim + 0.5 <= 90 [ set risk-asim risk-asim + 0.5 ] if client-risk < risk and risk-asim - 0.5 >= 10 [ set risk-asim risk-asim - 0.5 ] ] ] ] let out-linked-turtles out-link-neighbors ;; supplier side it checks if it has clients if random-float 1 < prob-of-risk-propagation [ if any? out-linked-turtles [ let supplier-risk risk ask out-linked-turtles [ if supplier-risk > risk and risk-asim + 0.5 <= 90 [ set risk-asim risk-asim + 0.5 ] if supplier-risk < risk and risk-asim - 0.5 >= 10 [ set risk-asim risk-asim - 0.5 ] ] ] ] ] ask turtles [ set cash cash + net-payment set net-payment 0 if int xcor != cash [ facexy cash ycor forward 0.5 ] ] ask turtles [ let in-linked-turtles in-link-neighbors let out-linked-turtles out-link-neighbors if cash < min-pxcor [ emergency-credit ] if cash < min-pxcor [ ask out-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask in-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 2 ] ] set insolvency-losses insolvency-losses + loan? default-consequences ] ] ask turtles [ set mean-cash ( ( mean-cash * life ) + cash ) / ( life + 1 ) ] end to take-credit ask turtles [ let in-linked-turtles in-link-neighbors let out-linked-turtles out-link-neighbors if maturity? = 0 [ if cash >= 0 and cash - loan? < 0 [ set insolvency-losses insolvency-losses - ( cash - loan? ) ] if cash < 0 [ set insolvency-losses insolvency-losses + loan? ] set cash cash - loan? set loan? 0 if cash <= 0 [ set insolvencies insolvencies + 1 ask in-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask out-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 1 ] ] default-consequences ] ] ] end to give-credit ask turtles [ let in-linked-turtles in-link-neighbors let out-linked-turtles out-link-neighbors if cash-rating? = false [ if count my-in-links <= average-num-links [ set perceived-risk ycor * premium-large-firms ] if count my-in-links > average-num-links [ set perceived-risk ycor / premium-large-firms ] if maturity? > 0 and perceived-risk > monitoring-max-risk-threshold [ set cash cash - loan? if cash - loan? < 0 [ set insolvency-losses insolvency-losses - ( cash - loan? ) ] set loan? 0 set maturity? 0 if cash <= 0 [ ask in-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask out-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 1 ] ] set repealed-loans repealed-loans + 1 default-consequences ] ] if maturity? = -1 and perceived-risk <= initial-risk-threshold and xcor < 16 [ set cash cash + loan-amount set loan? loan-amount set total-loans total-loans + loan-amount set maturity? maturity + 1 ] ] if cash-rating? = true [ if maturity? > 0 and mean-cash <= max-mean-cash-level [ set cash cash - loan? if cash - loan? < 0 [ set insolvency-losses insolvency-losses - ( cash - loan? ) ] set loan? 0 set maturity? 0 if cash <= 0 [ ask in-linked-turtles [ if risk + 1 <= max-pycor [ set risk risk + 1 set ycor risk ] ] ask out-linked-turtles [ if risk-asim + 1 <= 90 [ set risk-asim risk-asim + 1 ] ] set repealed-loans repealed-loans + 1 default-consequences ] ] if maturity? = -1 and mean-cash >= max-mean-cash-level and xcor < 16 [ set cash cash + loan-amount set loan? loan-amount set total-loans total-loans + loan-amount set maturity? maturity + 1 ] ] ] end to emergency-credit let in-linked-turtles in-link-neighbors let out-linked-turtles out-link-neighbors if cash-rating? = false [ if count my-in-links <= average-num-links [ set perceived-risk ycor * premium-large-firms ] if count my-in-links > average-num-links [ set perceived-risk ycor / premium-large-firms ] if maturity? = -1 and perceived-risk <= initial-risk-threshold [ set cash cash + loan-amount set loan? loan-amount set total-loans total-loans + loan-amount set maturity? maturity + 1 ] ] if cash-rating? = true [ if maturity? = -1 and mean-cash >= max-mean-cash-level [ set cash cash + loan-amount set loan? loan-amount set total-loans total-loans + loan-amount set maturity? maturity + 1 ] ] end to default-consequences set defaults defaults + 1 set defaults-per-tick defaults-per-tick + 1 die end to turtles-birth if random-float 1 < prob-new-firm [ create-turtles 1 [ set risk-asim 50 set maturity? -1 ifelse random 99 < 60 [ set finalproducer? 0 ] [ set finalproducer? 1 + random 5 ] if finalproducer? > 0 [ set size 1.35 set shape "triangle" ] set cash random max-pxcor set risk random max-pycor setxy cash risk ] set total-num-firms total-num-firms + 1 ] ask turtles with [ my-out-links = no-links ] [ let random-num-links int random-normal average-num-links 2 if random-num-links > 0 and random-num-links <= count other turtles with [not in-link-neighbor? myself ] [ let choice ( n-of ( random-num-links ) ( other turtles with [not in-link-neighbor? myself ] ) ) if choice != nobody [ create-links-to choice ] ] ] ;;let random-num-links random average-num-links ;;if random-num-links <= count turtles - 1 [ let choice ( n-of (random-num-links) other turtles ) ;;if any? choice [ create-links-to choice ] ] ] ask links [ set thickness 0.14 ] end to links-renovation ask turtles [ if random-float 1 < prob-new-firm [ ;;it creates links let choice ( one-of ( other turtles with [not out-link-neighbor? myself ] ) ) if choice != nobody [ create-link-to choice ] ] if random-float 1 < prob-new-firm [ ;; it destroys links let choice ( one-of ( my-out-links ) ) if choice != nobody [ ask choice [die] ] ] ] ask links [ set thickness 0.14 ] end to update-plot set-current-plot "Defaults/firms per tick" set-current-plot-pen "defaults/firms" plot defaults-per-tick / turtles-per-tick * 100 set defaults-per-tick 0 set-current-plot "Number of firms" set-current-plot-pen "firms" plot count turtles set-current-plot-pen "finalproducer" plot count turtles with [ finalproducer? > 0 ] set-current-plot "Defaults" set-current-plot-pen "insolvencies" plot insolvencies set-current-plot-pen "defaults" plot defaults set-current-plot "loans" set-current-plot-pen "insolvency-losses" plot insolvency-losses set-current-plot-pen "total-of-loans" plot total-loans if total-loans > 0 [ set credit-performance insolvency-losses / total-loans ] set-current-plot "Mean life firms" set-current-plot-pen "life-firm" ask turtles [ set life-firm life-firm + life ] if count turtles > 0 [ plot life-firm / count turtles ] set life-firm 0 end