program bgtcfi ! ! SIMPLE OLG MODEL WITH GROWTH AND UNCERTAIN LIFETIMES ! ! Dynamic program of individuals ! ! V(j,a) = max u(c,1-l) + beta ps(j,j+1)* V(j+1,a') ! c,l,a' ! ! s.t. (1+gz) a' = (1+i) a + w eps(j) l -c+ psi-taxes ! ! where growing variables are detrended relative to technology ! trend (1+gz)^t ! ! Functional forms: ! u(c,1-l) = log c + gam log(1-l) ! F(KT,KI,L) = KT^thetT *KI^thetI * (ZL)^{1-thetT-thetI}, 2 sectors ! ! Input file requires values for ! ! alb = lower bound on asset holdings ! aub = upper bound on asset holdings ! alpha = sector 1 share ! beta = discount factor ! delt1 = depreciation rate on tangible capital, sector 1 ! deli1 = depreciation rate on intangible capital, sector 1 ! delt2 = depreciation rate on tangible capital, sector 2 ! deli2 = depreciation rate on intangible capital, sector 2 ! gam = parameter in utility ! gn = growth rate of population ! gz = growth rate of technology ! lam = degree of annuitization ! tran = common transfers to all ages ! taud = tax rate on distributions ! taul = tax rate on labor ! taupc = tax rate on corporate profits ! taupu = tax rate on unincorporated profits (distributed in full) ! tfp = TFP parameter = Z^{1-theta} ! thett1 = tangible capital share, sector 1 ! theti1 = intangible capital share, sector 1 ! thett2 = tangible capital share, sector 2 ! theti2 = intangible capital share, sector 2 ! debt = government borrowing ! gspend = government spending ! idebt = 0 if debt in levels, 1 if share of GDP ! ispend = 0 if gspend in levels, 1 if share of GDP ! irate = initial guess for interest rate ! tauc = initial guess for the tax rate on consumption ! J x 3 ! eps = labor productivity for ages j, j=1:J ! ps = probability of survival from j to j+1, j=1:J (Jth ignored) ! xi = age-dependent transfers for ages j=1:J ! beq,jbeq = nonaccidental bequest, age of bequester ! ! NOTE: edit file to change maximum age (jmax) or number of ! points grid points in asset grid (n). ! ! Output file is loaded into Matlab -- run plotbg to view results. ! ! The algorithm used for solving the fixed point is Gauss-Seidel. ! ! Ellen McGrattan, 6-26-08 ! Revised, 7-25-12 implicit none integer, parameter :: jmax=101,n=3000,npar=24,tmax=240,nx=2 integer :: i,j,t,idone,it,maxit,jbeq integer, dimension(jmax) :: jpi integer, dimension(jmax,n) :: opt integer, dimension(2) :: ipar real, dimension(npar) :: par real, dimension(jmax) :: cj,lj,aj,apj real, dimension(jmax) :: eps,ps,xi real, dimension(nx) :: x,x1,res real :: kapt1,kapt2,kapi1,kapi2,lab1,lab2,c,y, & crit,beq,mu0,sum1 external agg open(unit=5, file='bgtc.inp') open(unit=7, file='bgtc.nxt') open(unit=8, file='bg.dat') open(unit=9, file='tran.inp') ! ! Read in parameters ! do i=1,npar read(5,*) par(i) enddo read(5,*) ipar(1) read(5,*) ipar(2) ! ! Read in guess for the interest rate and the tax rate on consumption ! read(5,*) x(1) read(5,*) x(2) x1 = x ! ! Read in labor productivities, survival probabilities, and transfers ! do j=1,jmax read(5,*) eps(j),ps(j),xi(j) enddo ps(jmax) = 0. read(5,*) beq,jbeq ! ! Compute steady state ! maxit = 10 crit = 1.e-8 idone = 0 it = 0 opt = -1 ! ! 1. Hold tauc fixed and compute irate ! do while ((idone==0).and.(it0) then k1 = max(1,floor(float(opt(j,i))-max(2.,.1*n))) k2 = min(floor(float(opt(j,i))+max(2.,.1*n)),n) else k1 = 1 k2 = n endif rhs = -1.e+9 do k=k1,k2 at = (aub*float(k-1)+alb*float(n-k))/float(n-1) input(1) = tran+xi(j)+irate*a-(1.+gz)*at *(1.-lam*(1.-ps(j))) call static(input, output) rhs(k) = output(1)+beta*ps(j)*vnext(k) enddo kk = maxloc(rhs) k = kk(1) opt(j,i) = k v(i) = rhs(k) enddo vnext = v enddo ! ! Update distributions of asset holdings ! jpi(1) = kzero do j=1,jmax-1 jpi(j+1) = opt(j,jpi(j)) enddo ! ! Add everything up ! asset = 0. tkap = 0. lab = 0. c = 0. y = 0. cj = 0. lj = 0. aj = 0. apj = 0. do j=1,jmax input(2) = atw*eps(j) i = jpi(j) a = (aub*float(i-1)+alb*float(n-i))/float(n-1) if (j=1.) then l = 1. c = (nlinc+w)/pc endif if (c<=0.) then u = -1.e+9 c = 0. else u = log(c)+gam*log(1.-l) endif output = (/ u,c,l /) end subroutine static