-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotEffectiveTaxRate.m
55 lines (40 loc) · 1.11 KB
/
plotEffectiveTaxRate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#tb = Tax Brackets
#for example tb = [0, 7091, 20261, 40552, 80640];
#tr = Tax Rates
#for example tr = [14.5, 28.5, 37, 45, 48];
#Income interval
function plotEffectiveTaxRate(tb, tr, colour)
numtb = numel (tb);
numtr = numel (tr);
if (numtb != numtr)
disp ("The arrays must have the same size")
return
endif
clear x;
clear y;
if (exist("colour", "var") != 1)
colour = "b";
endif
x = 1:10:(120000);
for i=1:numtr
tr(i)=tr(i).* 0.01;
endfor
#auxiliary array, something like the maginal tax
k(1)=tr(1)*tb(2);
for i=2:(numtb-1)
k(i)= k(i-1) + tr(i)* (tb(i+1)-tb(i));
endfor
y = ( tr(1) ) .* (x>=tb(1)) .* (x<tb(2));
for i=2:(numtr-1)
y = y + ( (( k(i-1) + tr(i)*(x-tb(i)) )./x) .* (x>=tb(i)) .* (x<tb(i+1)));
endfor
i=numtr;
y = y + ( (( k(i-1) + tr(i)*(x-tb(i)) )./x) .* (x>=tb(i)));
y= y.*100;
h = plot(x,y);
title ("Effective Income Tax", "fontsize", 16);
xlabel("Income", "fontsize", 14);
ylabel("Effective Tax Rate (%)", "fontsize", 14);
set(h, "color", colour, "linewidth", 4);
set(gca, "linewidth", 2, "fontsize", 18);
endfunction