### Simulate Keynesian goods market model via iteration
#Clear the environment 
rm(list=ls(all=TRUE))
# Set number of parameterisations that will be considered
S=2
# Set fixed parameter values
c0=3
c1=0.8
#Create vector in which equilibrium solutions from different parameterisations will be stored
Y_eq=vector(length=S)
C_eq=vector(length=S)
#Create vector with exogenous variable that will change 
G0=vector(length=S)
G0[1]=5
G0[2]=6
# Initialise endogenous variables at arbitrary positive value 
Y=C=1
#Solve this system numerically through 1000 iterations based on the initialisation
for (i in 1:S){
  for (iteration in 1:1000){
  Y = C + G0[i]
  C = c0 + c1*Y
  } # close iterations loop
  
#Save results for different parameterisations in vector
Y_eq[i]=Y
C_eq[i]=C
} # close parameterisations loop
# Verify solution for Y*
Y_eq[1]           # numerical solution