You can find the source code for this file in the class repository. The direct link is here.

Let’s start with studying static labor supply. We will consider the decision of the agent under the following rule:

$\max_{c,h} \frac{c^{1+\eta}}{1+\eta} - \beta \frac{h^{1+\gamma}}{1+\gamma}\\ \text{s.t. } c = \rho \cdot w\cdot h -r + \mu - \beta_0 \cdot 1[h>0] \\$ The individual takes his wage $$w$$ as given, he chooses hours of work $$h$$ and consumption $$c$$ subject to a given non labor income $$\mu$$ as well as a tax regime defined by $$\rho,r$$. $$\beta_0$$ is a fixed cost associated with working.

We note already that the non labor income can control for dynamic labor supply since we can have $$\mu= b_t - (1+r)b_{t+1}$$. This is part of a larger maximization problem where the agents choose optimaly $$b_t$$ over time. We will get there next time.

## Interior solution

The first order conditions give us $$w(wh +r - \mu)^\eta = \beta h^\gamma$$. There is no closed-form but we can very quickly find an interior solution by using Newton maximization on the function $$f(x) = w(wh +r - \mu)^\eta - \beta h^\gamma$$. We iterate on

$x \leftarrow x - f(x)/f'(x).$

# function which updates choice of hours using Newton step
# R here is total unearned income (including taxes when not working and all)
ff.newt <- function(x,w,R,eta,gamma,beta) {
f0 = w*(w*x + R)^eta - beta*x^gamma
f1 =  eta*w^2 * (w*x + R)^(eta-1) - gamma * beta *x^(gamma-1)
x  = x - f0/f1
x  = ifelse(w*x + R<=0, -R/w + 0.0001,x) # make sure we do not step out of bounds for next iteration
x  = ifelse(x<0, 0.0001,x)
x
}

## Simulating data

We are going to simulate a data set where agents will choose participation as well as the number of hours if they decide to work. To do that we will solve for the interior solution under a given tax rate and compare this to the option of no-work.

p  = list(eta=-1.5,gamma = 0.8,beta=1) # define preferences
tx = list(rho=1,r=0) # define a simple tax
N=1000
simdata = data.table(i=1:N,X=rnorm(N))
simdata <- simdata[,lw := X     + rnorm(N)*0.2];      # add a wage which depends on X
simdata <- simdata[,mu := exp(0.3*X + rnorm(N)*0.2)]; # add non-labor income that also depends on X

# we then solve for the choice of hours and consumption
simdata <- simdata[, h := pmax(-mu+tx$r ,0)/exp(lw)+1] # starting value # for loop for newton method (30 should be enough, it is fast) for (i in 1:30) { simdata[, h := ff.newt(h,tx$rho*exp(lw),mu-tx$r,p$eta,p$gamma,p$beta) ]
}

# attach consumption, value of working
simdata <- simdata[, c  := tx$rho*exp(lw)*h + mu]; simdata <- simdata[, u1 := c^(1+p$eta)/(1+p$eta) - p$beta * h^(1+p$gamma)/(1+p$gamma) ];

At this point we can regress $$\log(w)$$ on $$\log(c)$$ and $$\log(h)$$ and find precisely the parameters of labor supply:

pander(summary(simdata[,lm(lw ~ log(c) + log(h))]))
Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.494e-16 1.677e-16 -2.679 0.007498
log(c) 1.5 9.006e-17 1.666e+16 0
log(h) 0.8 1.638e-16 4.884e+15 0
Fitting linear model: lw ~ log(c) + log(h)
Observations Residual Std. Error $$R^2$$ Adjusted $$R^2$$
1000 1.415e-15 1 1

The regression still works, among ecah individual who chooses to work, the FOC is still satified.

pander(summary(simdata[,lm(lw ~ log(c) + log(h))]))
Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.494e-16 1.677e-16 -2.679 0.007498
log(c) 1.5 9.006e-17 1.666e+16 0
log(h) 0.8 1.638e-16 4.884e+15 0
Fitting linear model: lw ~ log(c) + log(h)
Observations Residual Std. Error $$R^2$$ Adjusted $$R^2$$
1000 1.415e-15 1 1

## Heterogeneity in $$\beta$$

Finally we want to add heterogeneity in the $$\beta$$ parameter.

simdata <- simdata[,betai := exp(0.5*X+rnorm(N)*0.1)]
simdata <- simdata[, h := pmax(-mu+tx$r ,0)/exp(lw)+1] for (i in 1:30) { simdata <- simdata[, h := ff.newt(h,tx$rho*exp(lw),mu-tx$r,p$eta,p$gamma,betai) ] } # attach consumption simdata <- simdata[, c := exp(lw)*h + mu]; # let's check that the FOC holds sfit = summary(simdata[,lm(lw ~ log(c) + log(h) + log(betai))]) ## Warning in summary.lm(simdata[, lm(lw ~ log(c) + log(h) + log(betai))]): ## essentially perfect fit: summary may be unreliable expect_equivalent(sfit$r.squared,1)
expect_equivalent(coef(sfit)["log(c)",1],-p$eta) expect_equivalent(coef(sfit)["log(h)",1],p$gamma)

sfit2 = summary(simdata[,lm(lw ~ log(c) + log(h))])
expect_false(coef(sfit2)["log(c)",1]==-p$eta) pander(sfit2) Estimate Std. Error t value Pr(>|t|) (Intercept) -0.5342 0.01912 -27.94 2.457e-127 log(c) 2.42 0.01911 126.6 0 log(h) 0.607 0.02964 20.48 4.515e-78 Fitting linear model: lw ~ log(c) + log(h) Observations Residual Std. Error $$R^2$$ Adjusted $$R^2$$ 1000 0.1864 0.9654 0.9653 ## Simple case of $$\eta=0$$ p = list(eta=0,gamma = 0.8,beta=1,beta0=0) # define preferences tx = list(rho=1,r=0) # define a simple tax N=1000 simdata = data.table(i=1:N,X=rnorm(N)) simdata <- simdata[,lw := X + rnorm(N)*0.2]; # add a wage which depends on X simdata <- simdata[,mu := exp(0.3*X + rnorm(N)*0.2)]; # add non-labor income that also depends on X simdata <- simdata[,eps := rnorm(N)*0.1] simdata <- simdata[,betai := exp(0.5*X+eps)] simdata <- simdata[, h := (tx$rho*exp(lw)/betai)^(1/p$gamma)] sfit3 = summary(simdata[,lm(log(h) ~ lw + X)]) pander(sfit3) Estimate Std. Error t value Pr(>|t|) (Intercept) 0.004285 0.003898 1.099 0.2718 lw 1.231 0.02043 60.26 0 X -0.6027 0.021 -28.7 1.687e-132 Fitting linear model: log(h) ~ lw + X Observations Residual Std. Error $$R^2$$ Adjusted $$R^2$$ 1000 0.1231 0.9674 0.9674 sfit4 = summary(simdata[,lm(lw ~ log(h) + X)]) pander(sfit4) Estimate Std. Error t value Pr(>|t|) (Intercept) -0.0008776 0.002806 -0.3128 0.7545 log(h) 0.6373 0.01058 60.26 0 X 0.6016 0.007349 81.86 0 Fitting linear model: lw ~ log(h) + X Observations Residual Std. Error $$R^2$$ Adjusted $$R^2$$ 1000 0.08855 0.9923 0.9923 Then we can construct a counter-factual revenue p2 = list(eta=0,gamma = 1/sfit3$coefficients["lw","Estimate"],beta=1,beta0=0)
tx2 = tx
tx2$rho = 0.9 simdata <- simdata[, h2 := (tx2$rho*exp(lw)/betai)^(1/p2$gamma)] simdata[, list(totearnings =mean(exp(lw+h)), R1=mean((1-tx$rho)*exp(lw+h)),R2=mean((1-tx2$rho)*exp(lw+h2)) ,R3=mean((1-tx2$rho)*exp(lw+h)) )]
##    totearnings R1       R2      R3
## 1:     209.648  0 7.554228 20.9648
Fork me on GitHub