# Housing Market Model

No preview image

Model was written in NetLogo 6.0.2
•
Viewed 60 times
•
Downloaded 1 time
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

globals[ gini-index-reserve lorenz-points num-hholds cprice dp% stock-price salesfinalized foreclosedhomes] breed[houses house] ; houses houses-own [status foreclosed? forsale? rentprice occupant owner mortgage taxprice price askingprice bidlist tenure] breed[loans loan] ; loans loans-own [lender borrower cost remain intrate payment timeleft kind missedpayments asset] ;;; breed[banks bank] ; commercial/retail bank banks-own [firmbonds firmcredit hhmortgages hhcredit hhdeposits gbonds bbonds bankdeposits foreclosureproceeds currentaccount capitalaccount fbinterest fcinterest bdinterest hhminterest hhcinterest hhdinterest gbinterest bbinterest revenue expenses profit taxwithholdings bankdividends loanlist badloans] breed[cbanks cbank] ; central bank cbanks-own [gbonds bbonds bankdeposits gbinterest bbinterest bdinterest currentaccount revenue expenses profit taxwithholdings loanlist badloans] breed[firms firm] ; consumption producing firms firms-own [firmbonds firmcredit fbinterest fcinterest currentaccount wages fiscalspending consumption revenue expenses profit taxwithholdings bankdividends dividends employeelist loanlist] breed[hholds hhold] ; households hholds-own [status currentaccount hhmortgages hhcredit hhdeposits hhminterest hhmpayment hhcinterest hhdinterest consumption wages dividends capitalgains rentexpense rentincome income expenses taxwithholdings capitalaccount maxaffordability houselist renthouselist currentbidhouse currentbid loanlist stockowned] breed[governments government] governments-own[taxescollected cbprofits fiscalspending gbonds gbinterest currentaccount revenue expenses loanlist] to set-up clear-all reset-ticks ask patches [set pcolor blue] init-houses init-agents setup-hholds setup-firms update-houses update-lorenz-and-gini end to go tick set foreclosedhomes 0 ;QUARTERLY ACTIONS hholds-quarterly banks-quarterly firms-quarterly governments-quarterly ;MONTHLY ACTIONS repeat 3 [ ; three months in a quarter banks-interact government-interact firms-interact households-interact update-houses ] update-lorenz-and-gini end to init-houses set-default-shape houses "house" ask patches [ sprout-houses 1] ask houses[ set status "vacant" set occupant 0 set owner 0 set forsale? false set foreclosed? false set tenure 0 set price 75000 + (3000 * count houses in-radius 3) set taxprice .9 * price set askingprice taxprice set rentprice taxprice * rentportion set bidlist (list) set mortgage 0] ; FIX LATER TO RANDOMIZE MORTGAGES update-houses end to init-agents create-hholds (.95 * count houses) [set hidden? true set loanlist (list)] create-cbanks 1 [set hidden? true set loanlist (list)] create-banks 1[ set hidden? true set loanlist (list)] create-governments 1 [set hidden? true set loanlist (list)] create-firms 1 [set hidden? true set loanlist (list)] end to setup-hholds ask hholds [ set status "homeless" set consumption .01 * wealth set rentexpense 0 set currentaccount 20000 set wages exp (random-normal 8.4 .3) set houselist (list)] ask houses [ let temphouse self ask one-of hholds [ set houselist lput temphouse houselist ask temphouse [set owner myself]] ;set up the random mortgages let thishouse self let myowner owner let myprice price let mymortgage 0 ask myowner [ ; take out loan (mortgage) for the house let mortgagerate (cbankrate + .03) / 12 let loanamount .8 * myprice if loanamount > 0 [ hatch-loans 1 [ set mymortgage self set lender one-of banks set borrower myself set cost loanamount set intrate mortgagerate set timeleft random 360 set payment loanamount * (mortgagerate * ((1 + mortgagerate) ^ 360) / (((1 + mortgagerate) ^ 360) - 1)) set remain ((cost * ((1 + mortgagerate) ^ timeleft)) - (payment * ((((1 + mortgagerate) ^ timeleft) - 1) / mortgagerate))) let tempremain remain set asset thishouse set kind "hhmortgage" ask lender [ set hhmortgages hhmortgages + tempremain set capitalaccount capitalaccount - loanamount set loanlist lput myself loanlist] ask borrower [ set hhmortgages hhmortgages + tempremain set loanlist lput myself loanlist]]]] set owner myowner set mortgage mymortgage set rentprice taxprice * rentportion] ask hholds [ set houselist sort-on [(- prestige)] (turtle-set houselist) if empty? houselist = false [ ask first houselist [ set occupant myself set tenure 0 set status "homeowner"] set status "homeowner"]] repeat 10000[ ask one-of hholds [ set stockowned stockowned + 1]] end to setup-firms ask firms [ set currentaccount (exp (random-normal 13.1 .5)) ] end ;QUARTERLY ACTIONS to hholds-quarterly set salesfinalized 0 ask houses with [forsale? = true][ let mybidderlist sort-on [(- currentbid)] bidlist ifelse empty? mybidderlist = false [ let thishouse self set mybidderlist sort-on [(- currentbid)] bidlist let currentowner owner if foreclosed? = true [ set currentowner one-of banks] let currentresident occupant let currentprice price let newowner first mybidderlist let newprice [currentbid] of newowner let newmortgage 0 show currentowner ask newowner [ ; take out loan (mortgage) for the house let mortgagerate (cbankrate + .03) / 12 let maxpayment income - expenses if maxpayment > debttoincome * income [set maxpayment debttoincome * income] set maxpayment maxpayment - (hhmpayment + hhcinterest) let maxloan maxpayment / (mortgagerate * ((1 + mortgagerate) ^ 360) / (((1 + mortgagerate) ^ 360) - 1)) if maxloan > (capitalaccount / min-dpay) [set maxloan (capitalaccount / min-dpay)] let loanamount maxloan let downpayment currentprice - loanamount set capitalaccount capitalaccount - downpayment ; will pay the old owner this + loanamount from bank set hhdeposits hhdeposits - downpayment ask banks [ set hhdeposits hhdeposits - downpayment set capitalaccount capitalaccount - downpayment] if loanamount > 0 [ hatch-loans 1 [ set newmortgage self set lender one-of banks set borrower myself set cost loanamount set remain loanamount set intrate mortgagerate set asset thishouse set payment loanamount * (mortgagerate * ((1 + mortgagerate) ^ 360) / (((1 + mortgagerate) ^ 360) - 1)) set timeleft 360 set kind "hhmortgage" set missedpayments 0 ask lender [ set hhmortgages hhmortgages + loanamount set capitalaccount capitalaccount - loanamount set loanlist lput myself loanlist] ask borrower [ set hhmortgages hhmortgages + loanamount set loanlist lput myself loanlist]]] set houselist lput myself houselist] ifelse foreclosed? = false [ ask currentowner [ set currentaccount currentaccount + newprice set capitalgains capitalgains + (newprice - currentprice) if [status] of thishouse = "homeowner" and [tenure] of thishouse > 24 [ set capitalgains capitalgains - 250000] set houselist remove myself houselist if status = "homeowner" [ set status "homeless"]]][;if it is foreclosure then the bank gets the money ask currentowner [ set currentaccount currentaccount + newprice set foreclosureproceeds foreclosureproceeds + newprice ]] if status = "homeowner" [ set status "vacant" set occupant 0] set owner newowner set forsale? false set salesfinalized salesfinalized + 1 if mortgage != 0 [ ask mortgage [ let tempremain remain ask lender [ set capitalaccount capitalaccount + tempremain set hhmortgages hhmortgages - tempremain set loanlist remove myself loanlist] ask borrower[ set currentaccount currentaccount - tempremain set hhmortgages hhmortgages - tempremain set loanlist remove myself loanlist] die]] set mortgage newmortgage set foreclosed? false ask bidlist [ set currentbidhouse 0 set currentbid 0] set bidlist (list) set price newprice set taxprice price * .9 set rentprice taxprice * rentportion][;if nobody in list, decrease price by 5% set askingprice askingprice * .95]] ; ;if it's the most prestigious house they own, then the new owner will move into it (or will do in another section) show (word "Sales Finalized: " salesfinalized) ask hholds [ ;move into their highest prestige house, or into a home they own (if renter) if status = "landlord" [ if length houselist > 1 [ let myhomes sort-on [(- prestige)] turtle-set houselist let newhome first myhomes if [status] of newhome = "renter" [ let oldhome houses with [occupant = myself] let newoccupant self let oldoccupant [occupant] of newhome ask oldoccupant [ set status "homeless" set rentexpense 0] ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]] if [status] of newhome = "vacant" [ let oldhome houses with [occupant = myself] let newoccupant self ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]]]] if status = "homeowner" [ if length houselist > 1 [ let myhomes sort-on [(- prestige)] turtle-set houselist let newhome first myhomes if [status] of newhome = "renter" [ let oldhome houses with [occupant = myself] let newoccupant self let oldoccupant [occupant] of newhome ask oldoccupant [ set status "homeless" set rentexpense 0] ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]] if [status] of newhome = "vacant" [ let oldhome houses with [occupant = myself] let newoccupant self ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]]]] if status = "renter" [ if empty? houselist = false [ let newhome first houselist if [status] of newhome = "renter" [ let oldhome houses with [occupant = myself] let newoccupant self let oldoccupant [occupant] of newhome ask oldoccupant [ set status "homeless" set rentexpense 0] ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]] if [status] of newhome = "vacant" [ let oldhome houses with [occupant = myself] let newoccupant self ask oldhome [ set tenure 0 set status "vacant" set occupant 0] ask newhome [ set tenure 0 set status "homeowner" set occupant newoccupant]] set status "homeowner"]] ;list properties for sale set expenses (taxwithholdings / 3) + hhmpayment + consumption + rentexpense if hhcredit > 0 [ if empty? houselist = false [ if not any? (turtle-set houselist) with [forsale? = true][ let temphouselist but-first houselist ifelse empty? temphouselist = false [ ;sell an investment property ask one-of temphouselist [ set forsale? true set askingprice taxprice]][;sell their home ask one-of houselist [ set forsale? true set askingprice taxprice]]]]] set currentbidhouse 0 ;create list of properties each hhold can afford, list by prestigiousness if capitalaccount > 0 [ ;;figure out how much they can afford 1) loan portion should be either the rest of the portion after paying downpayment or the most they can make payments on and 2) the current state of their capitalaccount let maxpayment income - expenses if maxpayment > .4 * income [set maxpayment .4 * income] let mortgagerate (cbankrate + .03) / 12 let maxloan maxpayment / (mortgagerate * ((1 + mortgagerate) ^ 360) / (((1 + mortgagerate) ^ 360) - 1)) if maxloan > (capitalaccount / min-dpay) [set maxloan (capitalaccount / min-dpay)] set maxaffordability maxloan + capitalaccount let tempmax maxaffordability let purchaselist sort-on [(- prestige)] (houses with [askingprice < tempmax and forsale? = true]) ;take this list and bid randomly on one of the top 5 if empty? purchaselist = false [ let randomnumber 5 if length purchaselist < 5 [set randomnumber length purchaselist] set currentbidhouse item (random randomnumber) purchaselist]] ;; the top bidder will get the house next turn, and the other bidders will have to look for another house to buy ;will look for new apartment if the current one is too expensive and cannot afford home if status = "homeless" [ let myincome income let mylist houses with [status = "vacant" and owner != 0] let lowcostlist sort-on [(- prestige)] mylist with [rentprice < .3 * myincome] let mediumcostlist sort-on [(- prestige)] mylist with [rentprice >= (.3 * myincome) and rentprice <= (.4 * myincome)] let highcostlist sort-on [(- prestige)] mylist with [rentprice > (.4 * myincome) and rentprice < (1 * myincome)] let myrenthouse 0 ifelse empty? mediumcostlist = false [ ;move into first of this list set myrenthouse first mediumcostlist ][;check lowcostlist ifelse empty? lowcostlist = false [ ;move into first of this list set myrenthouse first lowcostlist ][;move into the highcostlist if empty? highcostlist = false [ set myrenthouse first highcostlist ]]] if myrenthouse != 0 [;if the housing lists showed something acceptable ask myrenthouse [ set occupant myself set status "renter" set tenure 0] set status "renter" set rentexpense [rentprice] of myrenthouse]] if status = "homeowner" [ let myhouses turtle-set houselist if any? myhouses with [status = "renter"] [ set status "landlord"]] if status = "landlord" [ let myhouses turtle-set houselist if not any? myhouses with [status = "renter"][ set status "homeowner"]] ] end to banks-quarterly ; pay dividends to firms ask banks [ if bankdividends > 0 [ let tempdividends bankdividends set currentaccount currentaccount - tempdividends ask firms [ set currentaccount currentaccount + tempdividends set bankdividends tempdividends]]] end to firms-quarterly ;turn short-term financing into long-term financing ask firms [ if firmcredit > 0 [ let bondamount firmcredit let interestrate (cbankrate + .04) / 12 hatch-loans 1 [ set lender one-of banks set borrower myself set cost bondamount set remain bondamount set intrate interestrate set payment (intrate / 12) * bondamount set timeleft 60 set kind "firmbonds" ask lender [ set firmcredit firmcredit - bondamount set firmbonds firmbonds + bondamount set loanlist lput myself loanlist] ask borrower [ set firmcredit firmcredit - bondamount set firmbonds firmbonds + bondamount set loanlist lput myself loanlist]]] ;pay dividends to hholds ask hholds [set dividends 0] if dividends > 0 [ let tempdividends dividends let EPS tempdividends / 10000 set currentaccount currentaccount - tempdividends ask hholds [ set dividends dividends + (EPS * stockowned) set currentaccount currentaccount + (EPS * stockowned)] set dividends 0] if bankdividends > 0 [ let tempdividends bankdividends let EPS tempdividends / 10000 set currentaccount currentaccount - tempdividends ask hholds [ set dividends dividends + (EPS * stockowned) set currentaccount currentaccount + (EPS * stockowned)] set bankdividends 0]] end to governments-quarterly ;government collects withhelds taxes from banks, households and firms ask governments[ let firmtaxes sum [taxwithholdings] of firms let hholdtaxes sum [taxwithholdings] of hholds let banktaxes sum [taxwithholdings] of banks set taxescollected firmtaxes + hholdtaxes + banktaxes set currentaccount currentaccount + taxescollected set revenue taxescollected set fiscalspending fiscalspending + (.1 * (revenue - expenses)) ask firms[ set currentaccount currentaccount - taxwithholdings set taxwithholdings 0] ask banks[ set currentaccount currentaccount - taxwithholdings set taxwithholdings 0] ask hholds[ let hhtaxes taxwithholdings set hhdeposits hhdeposits - taxwithholdings ask banks [ set hhdeposits hhdeposits - hhtaxes set capitalaccount capitalaccount - hhtaxes] set taxwithholdings 0]] end ;MONTHLY ACTIONS to banks-interact ask firms[ set fbinterest 0 set fcinterest 0] ask hholds[ set hhcinterest 0] ask cbanks[ set bbinterest 0 set bdinterest 0] ask banks[ set fbinterest 0 set fcinterest 0 set hhcinterest 0 ;banks collect interest on bonds and loans let temploans turtle-set loanlist ask temploans with [kind = "firmbonds"][ let tempamount payment ask borrower [ set currentaccount currentaccount - tempamount set fbinterest fbinterest + tempamount] ask lender [ set currentaccount currentaccount + tempamount set fbinterest fbinterest + tempamount] let tempremain remain if timeleft = 0 [;they cash the bond ask lender [ set capitalaccount capitalaccount + tempremain set firmbonds firmbonds - tempremain set loanlist remove myself loanlist] ask borrower[ set currentaccount currentaccount - tempremain set firmbonds firmbonds - tempremain set loanlist remove myself loanlist] die] set timeleft timeleft - 1]] ask firms [ let cintamount firmcredit * ((cbankrate + .08) / 12) set currentaccount currentaccount - cintamount set fcinterest fcinterest + cintamount ask banks [ set currentaccount currentaccount + cintamount set fcinterest fcinterest + cintamount]] ask hholds [ let cintamount hhcredit * ((cbankrate + .12) / 12) set currentaccount currentaccount - cintamount set hhcinterest hhcinterest + cintamount ask banks [ set currentaccount currentaccount + cintamount set hhcinterest hhcinterest + cintamount]] ; banks pay interest to depositors ask hholds [ let tempinterest (cbankrate / 12) * hhdeposits set hhdinterest tempinterest set currentaccount currentaccount + tempinterest ask banks [ set hhdinterest hhdinterest + tempinterest set currentaccount currentaccount - tempinterest]] ask banks[ ;banks pay interest to CB let temploans turtle-set loanlist ask temploans with [kind = "bbonds"][ let tempamount payment ask borrower [ set currentaccount currentaccount - tempamount set bbinterest bbinterest + tempamount] ask lender [ set currentaccount currentaccount + tempamount set bbinterest bbinterest + tempamount] let tempremain remain if timeleft = 0 [;they cash the bond ask lender [ set currentaccount currentaccount + tempremain set bbonds bbonds - tempremain set loanlist remove myself loanlist] ask borrower[ set currentaccount capitalaccount - tempremain set bbonds bbonds - tempremain set loanlist remove myself loanlist] die] set timeleft timeleft - 1] ;collect interest from CB deposits if capitalaccount > 0[ let tempinterest capitalaccount * cbankrate ask one-of cbanks [ set currentaccount currentaccount - tempinterest set bdinterest bdinterest + tempinterest] set currentaccount currentaccount - tempinterest set bdinterest bdinterest + tempinterest] ;banks withhold taxes set revenue fbinterest + fcinterest + hhcinterest + hhminterest + gbinterest + bdinterest + foreclosureproceeds set expenses hhdinterest + bbinterest + badloans set profit revenue - expenses set taxwithholdings corporatetaxrate * profit set bankdividends (1 - corporatetaxrate) * profit set fbinterest 0 set fcinterest 0 set hhcinterest 0 set hhminterest 0 set gbinterest 0 set bdinterest 0 set foreclosureproceeds 0 set hhdinterest 0 set bbinterest 0 set badloans 0 ;if there is a profit, banks pay profits to firms to be given as dividends ;banks will shore up inadequate funds be reinvesting profits first, and then taking CB loans if that isn't sufficient if currentaccount < 0 [ set capitalaccount capitalaccount + currentaccount set currentaccount currentaccount - currentaccount] if capitalaccount < 0 [;use profits to shore up capital needs let capitalneeded -1 * capitalaccount if bankdividends > capitalneeded [ set currentaccount currentaccount - capitalneeded set capitalaccount capitalaccount + capitalneeded set bankdividends bankdividends - capitalneeded] if bankdividends < capitalneeded [ set currentaccount currentaccount - bankdividends set capitalaccount capitalaccount + bankdividends set bankdividends bankdividends - bankdividends] if capitalaccount < 0 [ let tempborrower self let templender one-of cbanks let bondamount -1 * capitalaccount let interestrate (cbankrate / 12) hatch-loans 1 [ set lender templender set borrower tempborrower set cost bondamount set remain bondamount set intrate interestrate set payment (intrate / 12) * bondamount set timeleft 0 set kind "bbonds" ask lender [ set currentaccount currentaccount - bondamount set bbonds bbonds + bondamount set loanlist lput myself loanlist] ask borrower [ set capitalaccount capitalaccount + bondamount set bbonds bbonds + bondamount set loanlist lput myself loanlist]]]] ] end to government-interact ;collect CB profits ask cbanks [ set revenue gbinterest + bbinterest set expenses bdinterest set profit revenue - expenses if profit > 0 [ let tempprofit profit set currentaccount currentaccount - tempprofit ask governments [ set cbprofits tempprofit set currentaccount tempprofit]] set gbinterest 0 set bbinterest 0 set bdinterest 0] ;spends fiscal to firms ask governments [ let tempfiscal fiscalspending set currentaccount currentaccount - tempfiscal ask firms [ set fiscalspending tempfiscal set currentaccount currentaccount + tempfiscal] ;pays bond interest to CB and banks set gbinterest 0 ask banks [ set gbinterest 0] ask cbanks [ set gbinterest 0] let temploans turtle-set loanlist ask temploans with [kind = "gbonds"][ let tempamount payment ask borrower [ set currentaccount currentaccount - tempamount set gbinterest gbinterest + tempamount] ask lender [ set currentaccount currentaccount + tempamount set gbinterest gbinterest + tempamount] let tempremain remain if timeleft = 0 [;they cash the bond ask lender [ set currentaccount currentaccount - tempremain set gbonds gbonds - tempremain] ask borrower[ set currentaccount currentaccount + tempremain set gbonds gbonds - tempremain] die] set timeleft timeleft - 1] ;covers deficit by releasing bonds to CB if currentaccount < 0[ let tempborrower self let templender one-of cbanks let bondamount -1 * currentaccount let interestrate (cbankrate / 12) hatch-loans 1 [ set lender templender set borrower tempborrower set cost bondamount set remain bondamount set intrate interestrate set payment (intrate / 12) * bondamount set timeleft 12 set kind "gbonds" ask lender [ set currentaccount currentaccount - bondamount set gbonds gbonds + bondamount set loanlist lput myself loanlist] ask borrower [ set currentaccount currentaccount - bondamount set gbonds gbonds + bondamount set loanlist lput myself loanlist]]]] end to firms-interact ;firms calculate profits from last turn ask firms [ set revenue fiscalspending + consumption set expenses fbinterest + fcinterest + wages set profit revenue - expenses set taxwithholdings profit * corporatetaxrate ;determine withholdings for taxes set dividends profit - taxwithholdings ;take out credit if needed if currentaccount < 0 [ let creditneeded -1 * currentaccount set currentaccount currentaccount + creditneeded set firmcredit firmcredit + creditneeded ask banks [ set firmcredit firmcredit + creditneeded set capitalaccount capitalaccount - creditneeded]] ;pay workers (this is start of new turn) let totalwages sum [wages] of hholds set wages totalwages set currentaccount currentaccount - totalwages ask hholds [ set currentaccount currentaccount + wages] set consumption 0 set fiscalspending 0 set fbinterest 0 set fcinterest 0] end to households-interact ask houses [ let thishouse self set bidlist hholds with [currentbidhouse = thishouse]] ask hholds [ if not any? houses with [occupant = myself][ set status "homeless"] ;set desired consumption based on wages, wealth, and **networks** set consumption (.3 * income) + 600 + (.001 * wealth) + (((random-poisson 1) / 3) * income) ;buy consumption from the firm let tempconsumption consumption set currentaccount currentaccount - tempconsumption ask firms [ set currentaccount currentaccount + tempconsumption set consumption consumption + tempconsumption] set rentincome 0 set hhminterest 0 set hhmpayment 0] ;pay rent to landlords ask houses with [status = "renter"][ let temprent rentprice ask occupant[ set currentaccount currentaccount - temprent set rentexpense temprent] ask owner[ set currentaccount currentaccount + temprent set rentincome rentincome + temprent]] ask loans with [kind = "hhmortgage"][ let tempamount payment let tempinterest remain * intrate let tempprinciple payment - tempinterest ifelse tempamount < (([currentaccount] of borrower) + ([capitalaccount] of borrower)) [ ask borrower [ set currentaccount currentaccount - tempamount set hhmortgages hhmortgages - tempprinciple set hhmpayment hhmpayment + tempamount set hhminterest hhminterest + tempinterest] ask lender [ set currentaccount currentaccount + tempinterest set hhminterest hhminterest + tempinterest set capitalaccount capitalaccount + tempprinciple set hhmortgages hhmortgages - tempprinciple] set remain remain - tempprinciple let tempremain remain if timeleft = 0 [;they cash the bond ask lender [ set currentaccount currentaccount + tempremain set hhminterest hhminterest + tempremain set loanlist remove myself loanlist] ask borrower[ set currentaccount currentaccount - tempremain set hhminterest hhminterest + tempremain set loanlist remove myself loanlist] ask asset[ set mortgage 0] die] set missedpayments 0 set timeleft timeleft - 1][ ifelse missedpayments > 3[;start forclosure if remain > [taxprice] of asset [ let thishouse asset let tempbad remain ask asset [ set forsale? true set foreclosed? true set foreclosedhomes foreclosedhomes + 1 set askingprice tempbad set mortgage 0 set owner 0 set status "vacant" if occupant != 0 [ ask occupant [ set status "homeless"]] set occupant 0] ask lender [ set badloans badloans + tempbad set hhmortgages hhmortgages - tempbad set loanlist remove myself loanlist] ask borrower [ set houselist remove thishouse houselist set loanlist remove myself loanlist] die ]][;don't start forclosure set missedpayments missedpayments + 1]]] ;calculate withholdings for income, and property taxes ask hholds [ let propertyvalues sum [taxprice] of (turtle-set houselist) let propertytax (propertyvalues * propertytaxrate) / 12 ; what the monthly portion for the tax would be set income (dividends / 3) + wages + rentincome + hhdinterest let taxableincome income - 1733.33 ; taxableincome less the standard deduction and personal deductions let incometax 0 let capitalgainstaxrate 0 if taxableincome >= 0 and taxableincome < 1554.25 [ ; monthly brackets based on 2017 income tax brackets for Federal taxes set incometax 0 + 0.1 * (taxableincome - 0)] if taxableincome >= 1554.25 and taxableincome < 6325 [ set incometax 155.42 + 0.15 * (taxableincome - 1554.25)] if taxableincome >= 6325 and taxableincome < 12758.42 [ set incometax 1104.17 + 0.25 * (taxableincome - 6325) set capitalgainstaxrate .15] if taxableincome >= 12758.42 and taxableincome < 19445.92 [ set incometax 4293.75 + 0.28 * (taxableincome - 12758.42) set capitalgainstaxrate .15] if taxableincome >= 19445.92 and taxableincome < 34725 [ set incometax 9738.58 + 0.33 * (taxableincome - 19445.92) set capitalgainstaxrate .15] if taxableincome >= 34725 and taxableincome < 39225 [ set incometax 21197.83 + 0.35 * (taxableincome - 34725) set capitalgainstaxrate .15] if taxableincome >= 39225 [ set incometax 34926.58 + 0.396 * (taxableincome - 39225) set capitalgainstaxrate .2] let capitalgainstaxes 0 if capitalgains > 0 [ set capitalgainstaxes capitalgainstaxrate * capitalgains] ; capital gains tax rate depends on income tax bracket set capitalgains 0 set taxwithholdings propertytax + incometax + capitalgainstaxes set currentaccount currentaccount - taxwithholdings set hhdeposits hhdeposits + taxwithholdings ;set taxwithholdings taxwithholdings + (capitalgainstaxes * capitalgains) ;put taxwithholdings into deposits let tempmoney (currentaccount) ;pay off credit with leftover money ;transfer leftover money to savings in capital account if currentaccount > 0 [;pay off credit with leftover money if hhcredit > 0 [ let amountowed hhcredit ifelse amountowed < tempmoney [;if the hhold can pay it off right away set tempmoney tempmoney - amountowed set currentaccount currentaccount - amountowed set hhcredit hhcredit - amountowed ask banks [ set hhcredit hhcredit - amountowed set capitalaccount capitalaccount + amountowed]][ ;if the hhold can only pay part of it set amountowed tempmoney set tempmoney tempmoney - amountowed set currentaccount currentaccount - amountowed set hhcredit hhcredit - amountowed ask banks [ set hhcredit hhcredit - amountowed set capitalaccount capitalaccount + amountowed]]]] ;transfer the rest to capitalaccount if currentaccount > 0 [ set tempmoney currentaccount set currentaccount currentaccount - tempmoney set hhdeposits hhdeposits + tempmoney ask banks [ set hhdeposits hhdeposits + tempmoney set capitalaccount capitalaccount + tempmoney] set capitalaccount capitalaccount + tempmoney] if currentaccount < 0 [;set credit higher (short term solution) let creditneeded -1 * currentaccount set currentaccount currentaccount + creditneeded set hhcredit hhcredit + creditneeded ask banks [ set hhcredit hhcredit + creditneeded set capitalaccount capitalaccount - creditneeded]] if hhcredit > 0 [ if capitalaccount > 0 [ set tempmoney capitalaccount let amountowed hhcredit ifelse amountowed < tempmoney [;if the hhold can pay it off right away set capitalaccount capitalaccount - amountowed set hhdeposits hhdeposits - amountowed set hhcredit hhcredit - amountowed ask banks [ set hhdeposits hhdeposits - amountowed set capitalaccount capitalaccount - amountowed set hhcredit hhcredit - amountowed set capitalaccount capitalaccount + amountowed] ][ ;if the hhold can only pay part of it set amountowed capitalaccount set capitalaccount capitalaccount - amountowed set hhdeposits hhdeposits - amountowed ask banks [ set hhdeposits hhdeposits - amountowed set capitalaccount capitalaccount - amountowed set hhcredit hhcredit - amountowed set capitalaccount capitalaccount + amountowed] set hhcredit hhcredit - amountowed]]] if capitalaccount < 0 [ let creditneeded -1 * capitalaccount set capitalaccount capitalaccount + creditneeded set hhdeposits hhdeposits + creditneeded set hhcredit hhcredit + creditneeded ask banks [ set hhdeposits hhdeposits + creditneeded set capitalaccount capitalaccount + creditneeded set hhcredit hhcredit + creditneeded set capitalaccount capitalaccount - creditneeded]] ;hholds will raise their bid each month until they are the top bidder if currentbidhouse != 0 [ if capitalaccount > 0 [ ;;figure out how much they can afford 1) loan portion should be either the rest of the portion after paying downpayment or the most they can make payments on and 2) the current state of their capitalaccount let maxpayment income - expenses if maxpayment > .4 * income [set maxpayment .4 * income] let mortgagerate (cbankrate + .03) / 12 let maxloan maxpayment / (mortgagerate * ((1 + mortgagerate) ^ 360) / (((1 + mortgagerate) ^ 360) - 1)) if maxloan > (capitalaccount / min-dpay) [set maxloan (capitalaccount / min-dpay)] set maxaffordability maxloan + capitalaccount let tempmax maxaffordability let tempbidlist [bidlist] of currentbidhouse set tempbidlist sort-on [(- currentbid)] tempbidlist if first tempbidlist != self [ ;if hhold is not the highest bidder, they will try and increase bid based on their maxaffordability let currenthighbid max [currentbid] of (turtle-set tempbidlist) if tempmax > currenthighbid [ set currentbid currenthighbid + ((tempmax - currenthighbid) * .2)]]]]] end to update-lorenz-and-gini let sorted-wealths sort [wealth] of hholds let total-wealth sum sorted-wealths let wealth-sum-so-far 0 let index 0 set gini-index-reserve 0 set num-hholds count hholds set lorenz-points [] repeat num-hholds [ set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths) set lorenz-points lput ((wealth-sum-so-far / total-wealth) * 100) lorenz-points set index (index + 1) set gini-index-reserve gini-index-reserve + (index / num-hholds) - (wealth-sum-so-far / total-wealth)] end to update-houses ask houses [ set tenure tenure + 1 if status = "vacant" [set color red] if status = "renter" [set color green] if status = "homeowner" [set color brown] set taxprice mean [taxprice] of (houses in-radius 3) ] end to-report wealth let mywealth capitalaccount if houselist != 0 [ let myhouses turtle-set houselist set mywealth mywealth + sum [taxprice] of myhouses] report mywealth end to-report prestige let deedneighbors (list houses in-radius 4) let myprestige taxprice / 100000 if empty? deedneighbors = false [foreach deedneighbors [deedneighbor -> ask deedneighbor[ let myowner occupant if status = "vacant" [ set myprestige myprestige - 1] if myowner != 0 [ if [status] of myowner = "renter" [ set myprestige myprestige + 0] if [status] of myowner = "homeowner" [ set myprestige myprestige + 1] if [status] of myowner = "landlord" [ set myprestige myprestige + 2]]]]] report myprestige end

There are 2 versions of this model.

## Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.