1. Introduction

This report analyzes a one-period economic model comprising households, firms, and a government.

The model focuses on determining the equilibrium outcomes for private consumption (\(c\)), government goods (\(g\)), hours worked (\(h\)), and total output (\(y\)) under various tax rates (\(\tau\)).

Additionally, we compute the optimal tax rate (\(\tau^*\)) that maximizes utility and evaluate the sensitivity of equilibrium outcomes to key parameters. This analysis was performed using R, and the results are presented through computational outputs and graphical visualizations.


2. Model Description From Theoretical Analysis

Competitive Equilibrium

2.1 Household

  • The representative household’s utility function is expressed as: \[u(c, g, h) = \theta \log(c + \kappa g^\rho) + (1 - \theta) \log(1 - h)\] where;
    • \(c\): Private consumption.
    • \(g\): Government goods.
    • \(h\): Labour supply
    • \(\theta, \kappa, \rho > 0\): Parameters governing the weight of \(g\), elasticity, and preferences (utility).

2.2 Firm

The firm uses a linear production function: \(y = n\), where \(y\) is output, \(n\) is labour hired from the household and wage (\(w\)) is normalized to 1

2.3 Government

The government taxes household labour income (\(\tau\)) and uses the revenue to provide government goods: \[ g = \tau \cdot w \cdot h, \] where \(w=1\) is the normalized wage rate, (\(\tau\)) is the tax rate

Derivation of the Labour Supply Function

2.4 For varying \(g\):

The household maximizes utility subject to the budget constraint \(c = (1-\tau) w h\). The first-order condition gives: \[ (1-\tau) h + (1-\theta) \kappa (\tau h)^\rho - \theta (1-\tau) = 0 \]

2.5 For fixed \(g\): When \(g\) is held constant, the labour supply simplifies to: \[ h = \theta - \frac{(1-\theta) \kappa g^\rho}{1-\tau} \]


3. Computational Approach

3.1 Parameters

we use these parameters in our numerical analysis setup:

  • \(\theta = 0.5\)
  • \(\rho = 0.6\)
  • \(\kappa = 0.8\)
  • \(w =1\) (normalized wage rate)
  • \(\tau_{\text{initial}} = 0.25\) (initial tax rate)
  • \(\tau\): A sequence from 0 to 1 in steps of 0.05.

3.2 Equilibrium Computation

Equilibrium Labour Supply Analysis


3.3 Labour supply with varying \(g\)

Labour supply, private consumption, government goods, and total output are computed for various tax rates (\(\tau\)) by solving for labour supply (\(h\)) numerically. Here;

  • Households value leisure (1−\(h\)) in addition to private consumption (\(c\)) and public goods (\(g\)).
  • The tax rate (τ=0.25) reduces the disposable income, slightly discouraging work.
  • Labour supply is moderate because the households balance the trade-off between leisure and the utility derived from c and g. Since we know that \(h\)=\(y\), we can say that the output y is entirely dependent on the labour supply which in turn is influenced by the preference of the household and the tax rates

Plot of labour supply as a function of tax rate

Results are plotted to show how labour supply varies with the tax rate.


Key Observations

  • As taxes (\(\tau\)) increase, more income is allocated to \(g\) (government goods), reducing \(c\) (private consumption). There is a trade off between \(c\) and \(g\)
  • The equilibrium labour supply (h=0.372) balances the marginal utility of leisure, private consumption, and public goods.
  • At τ=0.25, the economy achieves a reasonable split between \(c\) and \(g\), reflecting moderate government intervention.
  • Labour supply (\(h\)) consistently declines as (\(\tau\)) increases, reflecting diminishing work incentives as taxes rise.
  • The linear production assumption means \(h\) directly determines output(\(y\)), so higher taxes reduce total output in this model.
  • The relationship is nonlinear: the marginal impact of increasing \(\tau\) on \(h\) becomes more pronounced at higher tax rates.
  • Allowing \(g\) to vary introduces a stabilizing effect on labour supply by linking taxes to utility gains from public goods.
  • Private consumption (\(c\)) declines proportionally with the increase in (\(g\)) (government goods), maintaining the total output (\(y\)).

3.4 Labour supply with Fixed \(g\)

Government goods (\(g\)) are held constant at their equilibrium value from a specific tax rate (\(\tau\)=0.25) and Labour supply is recomputed, ensuring valid values. At fixed tax rate of 0.25, government goods \(g\) will be fixed at the value 0.0929504

Plot of Labour supply with Fixed \(g\)


Key Observations

  • labour supply (\(h\)) reduces more steeply at higher values of the tax rate (\(\tau\))

  • As \(\tau\) increases, \(h\) decreases steadily, eventually reaching near zero at high tax rates

  • Fixed \(g\) removes the feedback between taxes and government goods, so households face diminishing returns from work as taxes rise.

  • Fixed \(g\) intensifies the labour supply decline because taxes do not translate into increased public goods that could offset the loss in disposable income.

  • As taxes increase, the household faces greater disincentives to work, leading to lower \(h\).

  • Fixing \(g\) highlights the labour disincentive effects of taxation without the offsetting benefits of increasing government goods.

  • Fixing \(g\) =0.0929504 removes the stabilizing feedback between \(\tau\) and \(g\) causing steeper declines in \(h\) and \(y\) as taxes rise.

  • Private consumption \(c\) is directly proportional to \(h\) so, it will also be lower due to the reduced labour supply.

  • \(c\) decreases linearly with \(\tau\), as higher taxes reduce disposable income. With having \(g\) fixed, no additional utility is gained from higher taxes and this reduces private consumption

  • \(y\) decreases directly with h because output is proportional to labour supply, so any decline in \(h\) will cause a decline in \(y\)


3.5 Comparing Varying and Fixed \(g\)

With varying \(g\), labor supply remains higher at moderate tax rates compared to fixed \(g\). At higher tax rates, both scenarios converge as disincentives to work dominate. When \(g\) varies, higher taxes fund more government goods, partially compensating for lost disposable income. Fixed \(g\) removes this feedback, making higher taxes less desirable.

Plot of varying and fixed g with \(h\) set to zero

This visualization overlays labor supply curves for scenarios where \(g\) varies with \(\tau\) and where \(g\) is fixed

Key Observations

  • Labor supply (\(h\)) is higher for most tax rates when \(g\) varies, as households derive utility from increasing government goods
  • Labor supply declines more steeply, as there is no additional utility contribution from higher
  • Allowing \(g\) to vary mitigates the disincentive effects of taxation, as the increased provision of public goods offsets some of the loss in disposable income.
  • Fixed \(g\) exacerbates labor disincentives, while varying \(g\) provides a stabilizing effect

4. Sensitivity analysis for \(\rho\) and \(\kappa\)

The sensitivity of labor supply to changes in \(\rho\) and \(\kappa\) is examined here. Sensitivity analysis results are overlaid on single plots to demonstrate parameter impacts. This represents the household’s preference for government goods.

4.1 Plot of sensitivity analysis


Key observations

  • Labor supply is computed and plotted for different values of \(\kappa\) while varying the tax rate.
  • Higher \(\kappa\) (impact of government goods) leads to slower decreases in labor supply for increasing tax rates as government goods are valued more, encouraging continued labour supply.
  • Higher \(\rho\) increases the marginal utility of \(g\), creating a stronger incentive for labor supply as \(\tau\) increases.
  • Changes in \(\rho\) (elasticity of government goods utility) shift the labor supply curve slightly but do not drastically alter trends.
  • Higher values of \(\kappa\) (utility weight for government goods) result in flatter labor supply curves
  • When \(\kappa\) is high, government goods contribute more to utility, encouraging labor supply even at higher tax rates. Conversely, lower \(\kappa\) shifts preference toward private consumption, causing labor supply to decrease more rapidly.
  • Lower \(\rho\) values reduce the utility derived from government goods, causing sharper drops in \(h\) as taxes rise.
  • Lower \(\kappa\) shifts preference toward \(c\), causing \(h\) to decline faster as \(\tau\) increases. This sensitivity analysis reveals that the outcomes are strongly influenced by the weight and elasticity parameters \(\kappa\) and \(rho\), shaping how \(c\), \(g\),\(ℎ\),and \(y\) respond to changes in \(\tau\).

5. Optimal Tax Rate \(\tau*\)

Key observations

  • A utility function combining consumption and leisure preferences is maximized to find the optimal tax rate (\(\tau∗\)).
  • Utility combines the benefits of consumption (\(c\)), government goods (\(g\)), and leisure (1−\(h\)). At \(\tau*\) = 0.2195, taxes are high but the increase in \(g\) (government goods) outweighs the reduction in \(c\) (private consumption). Households value government goods enough to compensate for lower private consumption.
  • Results are plotted, marking the optimal tax rate and corresponding utility on the graph.
  • The optimal tax rate is calculated using numerical optimization, and it balances the trade-off between private consumption and government goods to maximize utility.
  • The utility function is graphed with the optimal tax rate highlighted.
  • Utility peaks at an optimal tax rate of \(\tau*\) = 0.22 before declining. This is because moderate taxes balance the trade-off between private consumption and government goods, maximizing utility. Higher taxes reduce labor supply and utility, while lower taxes under fund government goods.
  • Moderate taxation provides a balance between private and public goods, highlighting the importance of labor supply in determining economic efficiency and utility.

Plot for Optimal Tax Rate

The Optimal Tax Rate is (\(\tau*\): 0.2195)

6. Extending Analysis

The analysis is now extended by introducing lump-sum taxes into the model and then simulating its effects on labor supply and welfare.

6.1 Theoretical Framework

The original utility function is given as:

\[u(c, g, h) = \theta \log(c + \kappa g^\rho) + (1 - \theta) \log(1 - h)\]

Introducing lump-sum taxes (\(T\)), the household’s budget constraint becomes:

\[c = wh - T\]

The household’s optimization problem becomes:

\[\max_h u(c, g, h) = \theta \log(wh - T + \kappa g^\rho) + (1 - \theta) \log(1 - h)\]

Taking the first-order condition and solving numerically, we derive labor supply as a function of lump-sum taxes.

6.2 Parameters and Utility Function

# Define parameters
theta <- 0.5    # Preference weight on consumption
rho <- 0.6      # Elasticity of government goods
kappa <- 0.8    # Parameter for government goods
w <- 1          # Normalized Wage rate
g <- 0.25       # Government goods
T_values <- seq(0, 1, by = 0.01) # Range of lump-sum taxes

# Utility function
utility <- function(h, T, w, theta, rho, kappa) {
  g <- T  # Government spending equals lump-sum taxes
  c <- w * h - T
  if (c <= 0 || h <= 0 || h >= 1) return(-Inf) # Prevent edge cases
  u <- theta * log(c + kappa * g^rho) + (1 - theta) * log(1 - h)
  return(u)
}

6.3 Solving for Equilibrium Labor Supply

# Find optimal labor supply for given T
optimal_labor <- function(T, w, theta, rho, kappa) {
  optimize(
    utility, interval = c(0, 1), maximum = TRUE, T = T, w = w,
    theta = theta, rho = rho, kappa = kappa
  )$maximum
}

# Compute labor supply and welfare for each T
results <- data.frame(T = T_values, labor = NA, welfare = NA)

for (i in seq_along(T_values)) {
  T <- T_values[i]
  suppressWarnings({
  h_star <- optimal_labor(T, w, theta, rho, kappa)
  u_star <- utility(h_star, T, w, theta, rho, kappa)
})
  results$labor[i] <- h_star
  results$welfare[i] <- u_star
}

# Remove invalid results
results <- results[is.finite(results$welfare) & results$welfare != -Inf, ]

6.4 Visualizing Results

# Plot labor supply vs T
plot(
  results$T, results$labor, type = "l", pch = 16, col="blue", lwd = 2,
  xlab = "Lump-Sum Tax (T)", ylab = "Labor Supply (h)",
  main = "Labor Supply vs Lump-Sum Tax"
)
grid()

# Plot welfare vs T
plot(
  results$T, results$welfare, type = "l", lwd = 2, pch = 16,col="red",
  xlab = "Lump-Sum Tax (T)", ylab = "Welfare (Utility)",
  main = "Welfare vs Lump-Sum Tax"
)
grid()

7. Analysis of Results

7.1 Labor Supply

  • As lump-sum taxes (\(T\)) increase, disposable income decreases for any given level of labor supply (\(h\)). This leads the households to adjust their behavior
  • Lump-sum taxes reduce the disposable income of households, regardless of their labor supply. This creates a wealth effect, where households feel poorer and adjust their behavior by increasing their labor supply to maintain consumption levels.
  • Initially, the marginal benefit of working decreases as part of earned income is taxed away. The household may reduce their labor supply slightly to preserve leisure (1- \(h\))
  • However, as lump-sum taxes continue to rise, the household faces increasing financial constraints. To maintain necessary consumption levels, they are compelled to work more, resulting in a sharp rise in labor supply at higher tax levels.
  • Economic intuition: This behavior shows a non-linear labor-leisure trade off, where the need to sustain consumption outweighs the utility derived from leisure at higher tax levels. Labor supply increases as lump sum taxes increase.

7.2 Welfare

  • Welfare decreases with increasing \(T\), this is caused by the reduction in disposable income and consumption utility.
  • The decline in welfare underscores the trade-off between government revenue and household well-being.
  • Welfare is derived from two components: utility from consumption (\(c\)), which shrinks as disposable income declines and utility from leisure (\(1-h\)), which decreases when the household is forced to work more in order to compensate for the tax-induced income loss.
  • As lump-sum taxes increase, disposable income (\(c=wh-T\)) shrinks for any given level of labor (\(h\)). This reduces the utility derived from consumption.
  • At the same time, households are forced to adjust labor supply downward, which impacts the balance between consumption and leisure, further reducing the household’s overall welfare.
  • Economic intuition: The decline in welfare demonstrates a fundamental trade-off : increasing government revenue through taxes directly reduces household welfare. Households lose both disposable income and the ability to optimize their labor-leisure balance, leading to a welfare loss.

8. Key Results from Data

8.1 Initial Tax Levels (\(T=0 \to T=0.2\))

  • Labor supply declines modestly, from 0.5 to 0.4.

  • Welfare drops slightly, reflecting manageable reductions in disposable income with values declining from -0.4 to -0.5

  • Intuition; At lower tax levels, households adjust their labor-leisure balance minimally, as the tax burden is moderate and the after-tax income remains sufficient. Welfare loss is moderate because (\(g =T\)) still provides noticeable benefits

8.2 Higher Tax Levels (\(T=0.2 \to T=0.6\))

  • Labor supply increases sharply, rising from 0.4 to 0.6 as taxes increase.
  • Welfare decreases significantly from -0.5 to -1.2, reflecting the compounding effects of reduced consumption and leisure utility.
  • Intuition; At these higher tax levels, the tax burden begins to impose severe constrains on household consumption, significantly reducing disposable income, forcing individuals to work more. The welfare loss increases as households are unable to maintain optimal consumption.

8.3 Very High Tax Levels (\(T=0.6 \to T=1\))

  • Labor supply continues to increase, approaching the upper bound as households work more to offset the increased tax burden.
  • Welfare experiences a steep decline, dropping from -1.2 to below -2.0.
  • Intuition;At very high tax levels, households are severely constrained. Government goods fail to compensate for the drastic reductions in disposable income. The marginal utility from labor approaches zero, and the welfare loss becomes unsustainable.

Conclusion

This report examines the equilibrium behavior of a one-period economic model with a representative household, firm, and government. The analysis evaluates labor supply, private consumption, government goods, and total output under varying and fixed public goods scenarios. From our results, we see how there is a delicate balance required in designs of tax policies. By understanding households respond to changes in tax and government goods we can create policies that optimize economic outcomes while ensuring the distribution of resources equitably. Extending the analysis shows how lump-sum taxes influence labor supply and welfare. Numerical simulations and graphical visualizations provide clear insights into the effects of these taxes on household decisions and welfare outcomes.

Key notes from this analysis;

  • Labor Supply: Increases due to the wealth effect, which encourages households to work more to maintain consumption.

  • Welfare: Declines due to reduced leisure and constrained consumption, despite the utility derived from government goods.

  • Efficiency vs Equity: Lump-sum taxes are efficient as they do not distort marginal labor decisions but are inequitable because of their regressive impact.


Appendix: R Code

R Codes used

# Parameters
phi <- 0.5       # theta
rho <- 0.6       # rho
kappa <- 0.8     # kappa
tau_initial <- 0.25 # Initial tax rate
w <- 1           # Wage rate
theta <- phi     # Assuming theta is the same as phi

# Define tau values
tau_values <- seq(0, 1, by = 0.05)

# Labour supply function with fixed g
labour_supply_fixed_g <- function(tau, g_constant) {
  h <- theta - ((1 - theta) * kappa * g_constant^rho) / (1 - tau)
  return(ifelse(h >= 0 & h <= 1, h, NA))  # Ensure h is in [0, 1] valid range
}

# Labour supply function for varying g
labor_supply <- function(h, tau) {
  (1 - tau) * h + (1 - theta) * kappa * (tau * h)^rho - theta * (1 - tau)
}

### Part 7: Equilibrium Labor Supply with Varying g
cat("\nPart 7: Equilibrium Labor Supply with Varying g\n")
compute_equilibrium_varying_g <- function(tau, w) {
  h <- uniroot(function(h) labor_supply(h, tau), lower = 0, upper = 1)$root
  c <- (1 - tau) * w * h  # Private consumption
  g <- tau * w * h        # Government goods
  y <- w * h              # Total output
  return(list(c = c, g = g, y = y, h = h))
}

# Compute equilibrium for varying g
equilibrium_results_varying_g <- data.frame(
  tau = tau_values,
  c = numeric(length(tau_values)),
  g = numeric(length(tau_values)),
  y = numeric(length(tau_values)),
  h = numeric(length(tau_values))
)

for (i in seq_along(tau_values)) {
  eq <- compute_equilibrium_varying_g(tau_values[i], w)
  equilibrium_results_varying_g$c[i] <- eq$c
  equilibrium_results_varying_g$g[i] <- eq$g
  equilibrium_results_varying_g$y[i] <- eq$y
  equilibrium_results_varying_g$h[i] <- eq$h
}
# Print results for Part 7 (Varying g)
cat("Results for Part 7 (Varying g):\n")
print(equilibrium_results_varying_g)

# Plot equilibrium labor supply with varying g
plot(
  equilibrium_results_varying_g$tau, equilibrium_results_varying_g$h,
  type = "l", col = "blue", lwd = 2,
  xlab = "Tax Rate (τ)", ylab = "Labour supply",
  main = "Equilibrium Labour Supply as a Function of Tax Rate", 
  panel.first = grid()
)

### Part 8: Labor Supply with Fixed g
cat("\nPart 8: Labor Supply with Fixed g\n")

# Compute g_constant for fixed g
g_constant <- tau_initial * w * equilibrium_results_varying_g$h[which.min(abs(tau_values - tau_initial))]

# Labor supply function for fixed g
labor_supply_fixed_g <- function(tau) {
  h <- theta - ((1 - theta) * kappa * g_constant^rho) / (1 - tau)
  return(ifelse(h >= 0 & h <= 1, h, NA))  # Ensure h is in [0, 1]
}

# Compute labor supply for varying τ with fixed g
h_fixed_g <- sapply(tau_values, labor_supply_fixed_g)
results_fixed_g <- data.frame(tau = tau_values, h = h_fixed_g)

# Print results for Part 8 (Fixed g)
cat("\nResults for Part 8 (Fixed g):\n")
print(equilibrium_results_fixed_g)

# Plot labor supply with fixed g
plot(
  results_fixed_g$tau, results_fixed_g$h,
  type = "l", col = "red", lwd = 2,
  xlab = "Tax Rate (τ)", ylab = "Labour Supply (h)",
  main = "Labour Supply with Fixed g", 
  panel.first = grid()
)
# Combine results
combined_results <- data.frame(
  tau = tau_values,
  h_varying_g = equilibrium_results_varying_g$h,
  h_fixed_g = equilibrium_results_fixed_g$h,
  c_varying_g = equilibrium_results_varying_g$c,
  c_fixed_g = equilibrium_results_fixed_g$c,
  g_varying_g = equilibrium_results_varying_g$g,
  g_fixed_g = equilibrium_results_fixed_g$g,
  y_varying_g = equilibrium_results_varying_g$y,
  y_fixed_g = equilibrium_results_fixed_g$y
)


### Part 9: Comparison of Labour Supply (Varying vs Fixed g)
cat("\nPart 9: Comparison of Labor Supply (Varying vs Fixed g)\n")

# labour supply function for fixed g to handle high tax rates
labor_supply_fixed_g <- function(tau) {
  h <- theta - ((1 - theta) * kappa * g_constant^rho) / (1 - tau)
  return(ifelse(is.nan(h) | h < 0 | tau == 1, 0, h))  # Set to 0 if invalid or at τ = 1
}

# Compute labour supply for varying τ with fixed g
h_fixed_g <- sapply(tau_values, labor_supply_fixed_g)
results_fixed_g <- data.frame(tau = tau_values, h = h_fixed_g)

# Overlay the two labour supply curves for comparison
plot(
  equilibrium_results_varying_g$tau, equilibrium_results_varying_g$h,
  type = "l", col = "blue", lwd = 2,
  xlab = "Tax Rate (τ)", ylab = "Labour Supply (h)",
  main = "Comparison of Labour Supply (Varying vs Fixed g)", 
  panel.first = grid()
)
lines(results_fixed_g$tau, results_fixed_g$h, col = "red", lwd = 2)
legend(
  "topright", legend = c("Varying g", "Fixed g"),
  col = c("blue", "red"), lty = 1, lwd = 2
)
# Interpretation
cat("\nInterpretation:\n")
cat("The graph shows the labor supply (h) for both scenarios:\n")
cat("- 'Varying g' (in blue) represents government spending changing with tax revenue.\n")
cat("- 'Fixed g' (in red) represents government spending held constant.\n")
cat("The comparison highlights how labor supply responds to changes in tax rates under each scenario.\n")
  
### Part 10: Sensitivity Analysis for ρ and κ
cat("\nPart 10: Sensitivity Analysis for ρ and κ\n")
# Define sequences for rho and kappa
rho_values <- seq(0.4, 0.8, by = 0.2)  # Sequence for rho
kappa_values <- seq(0.6, 1.0, by = 0.2)  # Sequence for kappa

# Function to compute labor supply for given parameters
compute_labor_supply <- function(tau_values, rho, kappa, w) {
  labor_supply <- function(h, tau) {
    (1 - tau) * h + (1 - phi) * kappa * (tau * h)^rho - phi * (1 - tau)
  }
  h_values <- numeric(length(tau_values))
  for (i in seq_along(tau_values)) {
    h_values[i] <- uniroot(function(h) labor_supply(h, tau_values[i]), lower = 0, upper = 1)$root
  }
  return(h_values)
}

cat("\nPart 10: Sensitivity Analysis for ρ and κ (All κ on the Same Graph)\n")

# Colors for different κ values
kappa_colors <- c("blue", "red", "green")

# Initialize the plot with the first κ value
plot(
  tau_values, compute_labor_supply(tau_values, rho_values[2], kappa_values[1], w),
  type = "l", col = kappa_colors[1], lwd = 2,
  xlab = "Tax Rate (τ)", ylab = "Labour Supply (h)",
  main = "Labour Supply for Different κ (Fixed ρ = 0.6)",
  ylim = c(0, 0.6)  # Set y-axis limits to accommodate all curves
)

# Add lines for other κ values
for (i in 2:length(kappa_values)) {
  h_values <- compute_labor_supply(tau_values, rho_values[2], kappa_values[i], w)
  lines(tau_values, h_values, col = kappa_colors[i], lwd = 2)
}

# Add a legend to distinguish κ values
legend(
  "topright", legend = paste("κ =", kappa_values),
  col = kappa_colors, lty = 1, lwd = 2, title = expression("Values of" ~ kappa)
)

### Part 11: Optimal Tax Rate
cat("\nPart 11: Find Optimal Tax Rate\n")

#  Define utility function
utility_function <- function(tau) {
  h <- uniroot(function(h) labor_supply(h, tau), lower = 0, upper = 1)$root
  c <- (1 - tau) * w * h
  g <- tau * w * h
  return(phi * log(c + kappa * g^rho) + (1 - phi) * log(1 - h))
}
# Find optimal tau
optimal_tau <- optimize(utility_function, interval = c(0, 1), maximum = TRUE)$maximum
optimal_utility <- utility_function(optimal_tau)
cat(sprintf("\nOptimal Tax Rate (τ*): %.4f\n", optimal_tau))

# Compute utility for a range of tau values
utility_values <- sapply(tau_values, utility_function)

# Plot utility function
plot(
  tau_values, utility_values,
  type = "l", col = "blue", lwd = 2,
  xlab = "Tax Rate (τ)", ylab = "Utility (U)",
  main = "Utility as a Function of Tax Rate (τ)", 
  panel.first = grid()
)

# Mark the optimal tax rate on the graph
points(optimal_tau, optimal_utility, col = "red", pch = 16, cex = 2)  # Red dot for optimal point
arrows(optimal_tau - 0.1, optimal_utility - 0.1, optimal_tau, optimal_utility, 
       col = "red", length = 0.1, angle = 20, lwd = 2)  # Arrow pointing to the marker
text(optimal_tau - 0.12, optimal_utility - 0.12, 
     labels = bquote(tau^"*" == .(round(optimal_tau, 2))), 
     col = "red", cex = 1.2, font = 2)  # Annotate the optimal tax rate
# Define parameters
theta <- 0.5    # Preference weight on consumption
rho <- 0.6      # Elasticity of government services
kappa <- 0.8    # Scaling parameter for government goods
w <- 1          # Wage rate
T_values <- seq(0, 1, by = 0.1) # Range of lump-sum taxes

# Utility function
utility <- function(h, T, w, theta, rho, kappa) {
  g <- T  # Government spending equals lump-sum taxes
  c <- w * h - T
  if (c <= 0 || h <= 0 || h >= 1) return(-Inf) # Prevent edge cases
  u <- theta * log(c + kappa * g^rho) + (1 - theta) * log(1 - h)
  return(u)
}

# Find optimal labor supply for given T
optimal_labor <- function(T, w, theta, rho, kappa) {
  optimize(
    utility, interval = c(0, 1), maximum = TRUE, T = T, w = w,
    theta = theta, rho = rho, kappa = kappa
  )$maximum
}

# Compute labor supply and welfare for each T
results <- data.frame(T = T_values, labor = NA, welfare = NA)

for (i in seq_along(T_values)) {
  T <- T_values[i]
  suppressWarnings({
  h_star <- optimal_labor(T, w, theta, rho, kappa)
  u_star <- utility(h_star, T, w, theta, rho, kappa)
})
  results$labor[i] <- h_star
  results$welfare[i] <- u_star
}

# Remove invalid results
results <- results[is.finite(results$welfare) & results$welfare != -Inf, ]

# Plot labor supply vs T
plot(
  results$T, results$labor, type = "l", pch = 16, col="blue", lwd = 2,
  xlab = "Lump-Sum Tax (T)", ylab = "Labor Supply (h)",
  main = "Labor Supply vs Lump-Sum Tax"
)
grid()

# Plot welfare vs T
plot(
  results$T, results$welfare, type = "l", lwd = 2, pch = 16,col="red",
  xlab = "Lump-Sum Tax (T)", ylab = "Welfare (Utility)",
  main = "Welfare vs Lump-Sum Tax"
)
grid()