/
SIM B (1).R
99 lines (74 loc) · 2.59 KB
/
SIM B (1).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
#SIM B, R version, 9 October 2018
#Clear
rm(list=ls(all=TRUE))
#PERIODS (i= 1 to 65)
nPeriods=65
#NUMBER OF SCENARIOS
nScenarios=2
#PARAMETERS
alpha1=0.6
alpha2=0.4
theta=0.2
#VARIABLES
#Government expenditures
g=matrix(data=20,nrow=nScenarios,ncol=nPeriods)
#Income
y=matrix(data=g/theta,nrow=nScenarios,ncol=nPeriods)
#Income
y_star=matrix(data=y,nrow=nScenarios,ncol=nPeriods)
#Disposable income
yd=matrix(data=g*(1-theta)/theta,nrow=nScenarios,ncol=nPeriods)
#Consumption
c=matrix(data=yd,nrow=nScenarios,ncol=nPeriods)
#Wages
w=matrix(data=1,nrow=nScenarios,ncol=nPeriods)
#Labour
n=matrix(data=y/w,nrow=nScenarios,ncol=nPeriods)
#Taxes
t=matrix(data=theta*w*n,nrow=nScenarios,ncol=nPeriods)
#Cash demand
h_h=matrix(data=(1-alpha1)*yd/alpha2,nrow=nScenarios,ncol=nPeriods)
#Cash supply
h_s=matrix(data=h_h,nrow=nScenarios,ncol=nPeriods)
#Define scenario
for (j in 1:nScenarios){
#Define time
for (i in 2:nPeriods){
#Define iterations
for (iterations in 1:20){
#Government sp. passed from 20 to 25 after 15 periods in scenario 2
if (i>=15 && j==2){
g[j,i]=25
}
#Consumption function (SIM)
c[j,i] = alpha1*yd[j,i] + alpha2*h_h[j,i-1]
#Alternative consumption function (SIMEX)
#c[j,i] = alpha1*yd[j,i-1] + alpha2*h_h[j,i-1]
#Determination of output
y[j,i]= c[j,i] + g[j,i]
#Steady state solution --- additional equation
y_star[j,i] = g[j,i]/theta
#Determination of employment
n[j,i] = y[j,i]/w[j,i]
#Tax payments
t[j,i] = theta*w[j,i]*n[j,i]
#Disposable income derived from accounting identity
yd[j,i] = w[j,i]*n[j,i] - t[j,i]
#Increase in cash money, as a result of government deficit
h_s[j,i] = h_s[j,i-1] + g[j,i] - t[j,i]
#Increase in cash held by households
h_h[j,i] = h_h[j,i-1] + yd[j,i] - c[j,i]
}
}
}
#Tables
assign ("Tab1", (round(rbind(c[1,],y[1,],yd[1,]), digits=4)))
Table_base <- as.data.frame(Tab1,row.names=c('Consumption (c)','Income (y)','Disposable income (yd)'))
assign ("Tab2", (round(rbind(c[2,],y[2,],yd[2,]), digits=4)))
Table_shock <- as.data.frame(Tab2,row.names=c('Consumption (c)','Income (y)','Disposable income (yd)'))
#Figures
#Figure 3.1
plot(y_star[2,2:65],type="l",col="4",lwd=2,lty=1,font.main=1,cex.main=0.75,main="Figure 3.1: Impact of Y and Y* of a permanent increase in G",ylab = '',xlab = '',ylim=range(95,130))
lines(y[2,2:65],type="l",lwd=2,lty=1,col="3")
par(xpd=TRUE)
legend(10,-32,c("Steady state solution Y*","Income Y"), bty = 1, cex = 0.8, lty=c(1,1), lwd=c(2,2), col = c(4,3), box.lwd=0)