-
Notifications
You must be signed in to change notification settings - Fork 1
/
modelinit_bank_hurdle-runA.R
160 lines (132 loc) · 5.89 KB
/
modelinit_bank_hurdle-runA.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#----------------------------------------------
# modelinit_bank_hurdle.R
# Output of this model is loan terms given by a
# bank to meet their hurdle rate given a
# certain type of loan and incentive structure
#
# this script initializes the model inputs and
# calls bank_hurdle.R
#
# This script is modified from model_initialize.R
#
# Patricia Levi 03/2014
#----------------------------------------------
#source model contents
source('W:\\Research\\Energy Efficiency\\EE Finance toy model\\bank_hurdle.R')
# source newtons method solver
source('W:/Research/Energy Efficiency/EE Finance toy model/newton.solve.R')
source('W:\\Research\\Energy Efficiency\\EE Finance toy model\\excel_finance_functions.R')
### loads some pre-made R-copies of excel's finance functions. Thanks, the Internet! ###
### included: NPV(rate, values),
# IRR(x, start=0.1),
# FV(rate, nper, pmt, pv = 0.0, type = 0),
# PV(rate, nper, pmt, fv = 0.0, type = 0),
# PMT(rate, nper, pv, fv=0, type=0)
#-------------------#
# Initialize Inputs #
#-------------------#
#----------------------------------------------
# NB: any of the initial settings can be single numbers
# OR sets of testable numbers (eg. c(1,2,3) or seq(1,3,1))
#----------------------------------------------
#---------------#
# retrofit info #
#---------------#
eecost=13000 #cost of energy upgrade ($) - energy upgrade CA agv according to Zimring
savings.yr=2000 #yearly savings ($)
ee.lifetime = 15
#----------------#
# financing info #
#----------------#
tenor = 10# seq(5,15,by=5)#15 #loan tenor
# not really in use currently
# loan.frac = 1# fraction of eecost covered by loan
#---------------#
# discount info #
#---------------#
bank.hurdle = .0515#cost of capital http://pages.stern.nyu.edu/~adamodar/New_Home_Page/datafile/wacc.htm #.0075
user.discount = .15 #seq(.05,.25,by=.02)
gvt.discount = .04#seq(.01,.05,by=.01)
#------------#
# risky info #
#------------#
risk.adjust =.4 # as in (Amato, J., 2005) this number is used as follows
#!# # additional return (basis pts) required to compensate for risk = expected loss(i.e. 1-ev.pmt) * risk.adjust
# same source gives the .4 number
chance.full.loss = seq(.13,.30,by=.03) # i.e. chance of defaulting by end of loan tenor. 13% ~= 4% expected loss
recovery = .4 #pct of loan that is recovered on default
#-------------------#
# intervention info #
#-------------------#
# different types of interventions are separated by a "\n # \n"
#
interest.buydown = c(0,seq(0.01,0.15,by=0.01)) #amount that the gvt will buydown the interest rate
#
upfront.rebate = 0#eecost * c(0,.05)#seq(0,0.2,by=0.05)# .20 #20 percent buydown
#
#TO TURN OFF LOAN LOSS RESERVE, SET LSR=0
LPCR = seq(.02,.15,by=.01) # loan pool coverage ratio. usually around 5-10%
# cisco devries; "$10m gives about $200m of financing" for PACE.
LSR = c(0,.8) #loss-share ratio, usually ~90%. 0% --> no LLR
#--------------------#
# prepare inputs #
# for multiple values#
#--------------------#
# use expand.grid, which accepts a list of vectors
inlist = list(eecost = eecost,
savings.yr=savings.yr,
ee.lifetime = ee.lifetime,
tenor=tenor,
# loan.frac=loan.frac,
bank.hurdle = bank.hurdle,
user.discount = user.discount,
gvt.discount = gvt.discount,
chance.full.loss = chance.full.loss,
recovery=recovery,
LPCR = LPCR,
LSR = LSR,
interest.buydown = interest.buydown,
upfront.rebate = upfront.rebate,
risk.adjust=risk.adjust)
inputs = expand.grid (inlist)
#--------------------#
### call the model ###
#--------------------#
results = bankmodel(inputs)
#--------------------#
# save model run params
# and outputs
#--------------------#
folder = 'W:\\Research\\Energy Efficiency\\EE Finance toy model\\'
scenario = 'sensitivityTesting'#what set of non-intervention params do you want?
run.name='defaultRate' #used to save this set of params for later use/reference, should you desire.
save(list=c('inlist','inputs','results'), file=paste(folder,"model-runs\\",scenario,"-run-",run.name,sep=''))
# create some indices for viewing different subsets of the results
LLR = results[,"LSR"]>0 & results[,"upfront.rebate"]==0 & results[,"interest.buydown"]==0
IRB = results[,"LSR"]==0 & results[,"upfront.rebate"]==0 & results[,"interest.buydown"]>0
rebate = results[,"LSR"]==0 & results[,"interest.buydown"]==0
nothing = results[,"LSR"]==0 & results[,"upfront.rebate"]==0 & results[,"interest.buydown"]==0
no.loss=results[,"chance.full.loss"]==0
no.recovery = results[,"recovery"]==0
#-------------------------------------#
### to be implemented in the future ###
#-------------------------------------#
# partition bit of script into functions
#guarantee.frac = #fraction of loan that is guaranteed
# interest rate buydown
# upfront rebate
# showing the cost comparison between the above two
# loan-loss reserve
# incorporate risk/cost of customer default
# set-up to create a dataset for x vs y comparison
# ex - how cost to government changes as interest rate buydown changes
# -** plot cost to gvt on x axis, NPV to user on Y, compare interest rate and upfront rebate
# - how user NPV changes as user discount changes
# - how costs change as function of loan tenor
# - how risk of default changes banks' costs (i.e. importance of knowing if ee is notably less risky)
# output kWh (or $) saved per $ spent by gvt
#change model output to output a dataset, not print it
#!# Figure out how hurdle rate is some combo of riskiness and discount rate...
#!# so it would sort of account for part of the change_full_loss stuff??
# Tenor may be a model output?
# incorporate uncertainty in energy savings