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.
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
}
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))]))
## Warning in summary.lm(simdata[, lm(lw ~ log(c) + log(h))]): essentially
## perfect fit: summary may be unreliable
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
log(c) | 1.5 | 5.435e-17 | 2.76e+16 | 0 |
log(h) | 0.8 | 1.068e-16 | 7.491e+15 | 0 |
(Intercept) | -1.236e-15 | 1.091e-16 | -11.33 | 4.357e-28 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
1000 | 8.612e-16 | 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))]))
## Warning in summary.lm(simdata[, lm(lw ~ log(c) + log(h))]): essentially
## perfect fit: summary may be unreliable
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
log(c) | 1.5 | 5.435e-17 | 2.76e+16 | 0 |
log(h) | 0.8 | 1.068e-16 | 7.491e+15 | 0 |
(Intercept) | -1.236e-15 | 1.091e-16 | -11.33 | 4.357e-28 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
1000 | 8.612e-16 | 1 | 1 |
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))])
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|) | |
---|---|---|---|---|
log(c) | 2.375 | 0.01781 | 133.4 | 0 |
log(h) | 0.533 | 0.02829 | 18.84 | 5.837e-68 |
(Intercept) | -0.5746 | 0.01839 | -31.24 | 6.516e-150 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
1000 | 0.1787 | 0.9701 | 0.97 |
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|) | |
---|---|---|---|---|
lw | 1.223 | 0.01947 | 62.82 | 0 |
X | -0.6006 | 0.01977 | -30.39 | 4.493e-144 |
(Intercept) | -0.002831 | 0.003923 | -0.7216 | 0.4707 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
1000 | 0.124 | 0.9661 | 0.966 |
sfit4 = summary(simdata[,lm(lw ~ log(h) + X)])
pander(sfit4)
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
log(h) | 0.6527 | 0.01039 | 62.82 | 0 |
X | 0.5926 | 0.007018 | 84.44 | 0 |
(Intercept) | 0.002289 | 0.002866 | 0.7989 | 0.4245 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
1000 | 0.09057 | 0.992 | 0.992 |
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: 293736.3 0 1979.65 29373.63