En enero de 2015 entra en vigor la reforma fiscal propuesta por el ministro Montoro. Esta reforma modifica varias figuras impositivas, en este artículo nos centramos en el IRPF.
¿Por que analizar el IRPF? Por que básicamente es el impuesto estrella del gobierno por su importancia en recaudación y en los efectos en el mercado laboral.
In [133]:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------
# CARGAR LIBRERIAS
# ---------------------------------------------------------------------------------
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
import seaborn as sns
# ESTO INCRUSTA LOS GRAFICOS EN LA MISMA PAGINA
%matplotlib inline
sns.set_context(rc={"figure.figsize": (18, 13)})
print u"Introducimos datos para simular una serie de rentas para aplicar los tipos del IRPF y estudiar su comportamiento"
print u"La simulación por defecto crea una serie desde 5000 hasta 400000 con incrementos de 1000"
# r = raw_input(u"Para cambiar los parámetros de la simulación escriba 1, sino 0: ")
In [134]:
####################################################################################
#### DATOS ACTUALES DE IRPF #######
####################################################################################
base_actual = [0, 17707.20, 33007.20, 53407.20, 120000.00, 175000.00, 300000.00]
cuota_actual = [0, 4382.53, 8972.53, 17132.53, 48431.15, 75381.15, 139131.15]
t_actual = [0.2475, 0.3000, 0.4000, 0.470, 0.490, 0.510, 0.520]
####################################################################################
######### DATOS REFORMA DE 2015: ########
####################################################################################
t_estatal = [.10, .125, .155, .195, .235]
t_aragon = [.10, .125, .1550, .19, .215]
t_2015 = [t_estatal[i] + t_aragon[i] for i in range(5)]
base_2015 = [0, 12450.00, 20200.00, 34000.00, 60000.00]
cuota_2015 = [0, 2490, 4427.5, 8705.5, 18715.5]
In [135]:
####################################################################################
############## SIMULACIÓN E INCOGNITAS: ####################
####################################################################################
# SIMULAMOS UNA SERIE DE RENTAS:
# calculamos una serie de bases liquidas para simular el comportamiento. Agregar # al principio de la linea para activar la siguiente.
try:
if int(r) == 1:
base_sim = range(int(raw_input(">Renta de inicio: ")), int(raw_input(">Renta final: ")), int(raw_input(">Incremento: "))) # eliminar el primer # para controlar la simulacion
else:
base_sim = range(5000, 400000, 1000)
except (RuntimeError, TypeError, NameError):
base_sim = np.arange(1000, 400000, 100)
# DECLARAMOS LAS INCOGNITAS:
t_me_actual = []
t_mg_actual = []
ci_actual = []
ci_2015 = []
t_me_2015 = []
t_mg_2015 = []
In [136]:
####################################################################################
##### 2014: CALCULO DE CUOTA, TIPOS MARGINALES Y MEDIO DEL ACTUAL IRPF: ######
####################################################################################
'''
Para hallar las incognitas creo dos variables comp_actual e ind_actual,
el primero lo que hace es comparar la lista de las bases de cada tramo con la base
simulada y crea una lista que devuelve TRUE o FALSE para cada tramo, para saber
que indice es y poder aplicar los tipos y cuotas del tramo correspondiente aplicamos
ind_actual que busca el primer TRUE de y devuelve el indice al que corresponde el tramo.
'''
comp_actual = [[base_sim[i] <= base_actual[ii] for ii in range(len(base_actual))] for i in range(len(base_sim))]
ind_actual = []
for i in range(len(base_sim)):
if True in comp_actual[i]:
ind_actual.append(comp_actual[i].index(True) - 1)
else:
ind_actual.append(len(base_actual) - 1)
for i in range(len(base_sim)):
ci_actual.append(cuota_actual[ind_actual[i]] + (base_sim[i] - base_actual[ind_actual[i]]) * t_actual[ind_actual[i]])
t_mg_actual.append(t_actual[ind_actual[i]])
t_me_actual.append(ci_actual[i] / base_sim[i])
####################################################################################
# 2015: CALCULOS CUOTAS, TIPO MARGINAL Y TIPO MEDIO TRAS LA REFORMA 2015 #
####################################################################################
comp_2015 = [[base_sim[i] <= base_2015[ii] for ii in range(len(base_2015))] for i in range(len(base_sim))]
ind_2015 = []
for i in range(len(base_sim)):
if True in comp_2015[i]:
ind_2015.append(comp_2015[i].index(True) - 1)
else:
ind_2015.append(len(base_2015) - 1)
for i in range(len(base_sim)):
ci_2015.append(cuota_2015[ind_2015[i]] + (base_sim[i] - base_2015[ind_2015[i]]) * t_2015[ind_2015[i]])
t_mg_2015.append(t_2015[ind_2015[i]])
t_me_2015.append(ci_2015[i] / base_sim[i])
In [137]:
# ---------------------------------------------------------------------------------
# VISUALIZAR DATOS
# ---------------------------------------------------------------------------------
def ver_datos_ac():
print "{:^45}".format("DATOS IRPF GLOBAL 2014 PARA ARAGON")
print "{:^45}".format("=" * 45)
print "{:^10}\t{:^10}\t{:^10}".format("BASE", "CUOTA", "GRAVAMEN")
print "{:^10}\t{:^10}\t{:^10}".format("-" * 10, "-" * 10, "-" * 10)
for i in range(len(base_actual)):
print "{:>10.1f}\t{:>10.2f}\t{:>10.3f}".format(base_actual[i], cuota_actual[i], t_actual[i])
print "{:^45}".format("=" * 45)
print ""
plt.figure(figsize=(15,6), dpi=800)
plt.suptitle(u"IRPF GLOBAL 2014 PARA ARAGÓN", fontsize=15)
plt.plot(base_sim, t_mg_actual, linewidth=2)
plt.fill_between(base_sim, t_mg_actual, 0, alpha=0.3)
plt.yticks(t_actual, fontsize=12)
plt.xticks(base_actual, fontsize=12)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.margins(0.03)
plt.xlim(0,350000)
plt.show()
ver_datos_ac()
In [138]:
####################################################################################
###### PRESENTACION DE DATOS VISUALES #########
####################################################################################
# ---------------------------------------------------------------------------------
# CALCULOS ACTUAL:
# ---------------------------------------------------------------------------------
def ver_calculos_ac():
print "{:^70}".format("CALCULOS IRPF 2014 PARA ARAGON, MUESTRA FILTRADA")
print "{:^70}".format("="*70)
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("BASE","CUOTA","t\'","t*")
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("-"*10, "-"*10, "-"*10, "-"*10)
for i in range(0, len(base_sim), 150):
print "{:>10.0f}\t{:>10.2f}\t{:^10.3f}\t{:^10.3f}".format(base_sim[i], ci_actual[i], t_mg_actual[i], t_me_actual[i])
print "{:^70}".format("="*70)
ver_calculos_ac()
In [139]:
# ---------------------------------------------------------------------------------
# VISUALIZAR DATOS REFORMA 2015
# ---------------------------------------------------------------------------------
def ver_datos_2015():
print "{:^45}".format("DATOS IRPF GLOBAL 2015 PARA ARAGON")
print "{:^45}".format("=" * 45)
print "{:^10}\t{:^10}\t{:^10}".format("BASE", "CUOTA", "GRAVAMEN")
print "{:^10}\t{:^10}\t{:^10}".format("-" * 10, "-" * 10, "-" * 10)
for i in range(len(base_2015)):
print "{:>10.1f}\t{:>10.2f}\t{:>10.3f}".format(base_2015[i], cuota_2015[i], t_2015[i])
print "{:^45}".format("=" * 45)
print ""
ver_datos_2015()
plt.figure(figsize=(15,6), dpi=800)
plt.suptitle(u"DATOS IRPF GLOBAL 2015 PARA ARAGÓN", fontsize=15)
plt.plot(base_sim, t_mg_2015)
plt.fill_between(base_sim, t_mg_2015, 0, alpha=0.3)
plt.yticks(t_2015, fontsize=12)
plt.xticks(base_2015, fontsize=12)
plt.xlim(0,65000)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.margins(0.03)
plt.show()
In [140]:
# ---------------------------------------------------------------------------------
# VISUALIZAR LOS RESULTADOS IRPF 2015:
# ---------------------------------------------------------------------------------
# formatear como tabla '{0:>10}\t{1:>10}\t{2:^10}\t{3:^10}'.format("Base", "Cuota", "tme", "tmg")
# formatear como tabla numeros '{:>10.0f}\t{:>10.1f}\t{:^10.3f}\t{:^10.3f}'.format(base_sim[i], round(ci_2015[i], 3), round(t_me_2015[i], 3), round(t_mg_2015[i],3))
def ver_calculos_2015():
print "{0:^58}".format("RESULTADO CALCULOS IRPF 2015, MUESTRA FILTRADA")
print "=" * 58
print '{0:>10}\t{1:>10}\t{2:^10}\t{3:^10}'.format("Base", "Cuota", "tme", "tmg")
print '{0:>10}\t{0:>10}\t{0:>10}\t{0:>10}'.format("-"*10)
for i in range(0, len(base_sim), 500):
print '{:>10.0f}\t{:>10.1f}\t{:^10.3f}\t{:^10.3f}'.format(base_sim[i], round(ci_2015[i], 3), round(t_me_2015[i], 3), round(t_mg_2015[i],3))
print "=" * 58
ver_calculos_2015()
In [141]:
# ---------------------------------------------------------------------------------
# GRAFICO DE IRFP 2014:
# ---------------------------------------------------------------------------------
plt.figure(dpi=900)
plt.suptitle(u"Análisis Gráfico: Cuota y Base", fontsize=15)
plt.subplot(3,2,1)
plt.plot(ci_actual, t_mg_actual, label = "cuota_tmg_2014")
plt.plot(ci_actual, t_me_actual, label = "cuota_tme_2014")
plt.fill_between(ci_2015, t_mg_2015, t_me_2015, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.1)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.legend(loc = 0)
plt.subplot(3,2,3)
plt.plot(base_sim, t_mg_actual, label = "base_tmg_2014")
plt.plot(base_sim, t_me_actual, label = "base_tme_2014")
plt.fill_between(base_sim, t_mg_2015, t_me_2015, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.1)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.legend(loc = 0)
plt.subplot(3,2,5)
plt.plot(t_me_actual, base_sim, label = "base_tme_2014")
plt.plot(t_me_actual, ci_actual, label = "cuota_tme_2014")
plt.fill_between(t_me_2015, base_sim, ci_2015, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.1)
plt.xlabel("Tipo Impositivo")
plt.ylabel("Base, Cuota")
plt.legend(loc = 0)
plt.xticks([round(t_actual[i], 2) for i in range(len(t_actual))])
# Pinta poligonos color verde entre las lineas cuando y1 < y2
# ---------------------------------------------------------------------------------
# GRAFICO DE LOS RESULTADOS DE LA REFORMA 2015:
# ---------------------------------------------------------------------------------
plt.subplot(3,2,2)
plt.plot(ci_2015, t_mg_2015, label = "cuota_tmg_2015")
plt.plot(ci_2015, t_me_2015, label = "cuota_tme_2015")
plt.fill_between(ci_actual, t_mg_actual, t_me_actual, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.031)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.legend(loc = 0)
plt.subplot(3,2,4)
plt.plot(base_sim, t_mg_2015, label = "base_tmg_2015")
plt.plot(base_sim, t_me_2015, label = "base_tme_2015")
plt.fill_between(base_sim, t_mg_actual, t_me_actual, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.031)
plt.xlabel("Base")
plt.ylabel("Tipo Impositivo")
plt.legend(loc = 0)
plt.subplot(3,2,6)
plt.plot(t_me_2015, base_sim, label="base_tme_2015")
plt.plot(t_me_2015, ci_2015, label="cuota_tme_2015")
plt.fill_between(t_me_actual, base_sim, ci_actual, color = 'black', interpolate = True, alpha=0.1)
plt.margins(0.031)
plt.legend(loc = 0)
plt.xlabel("Tipo Impositivo")
plt.ylabel("Base, Cuota")
plt.xticks([round(t_2015[i], 2) for i in range(len(t_2015))])
plt.show()
In [142]:
####################################################################################
# ANALISIS DE LA PROGRESIVIDAD 2015:
####################################################################################
lp_actual = []
arp_actual = []
LP_2015 = [] # indice LP_2015
ARP_2015 = [] # indice ARP_2015
for i in range(len(base_sim)):
LP_2015.append(t_mg_2015[i] / t_me_2015[i])
ARP_2015.append((t_mg_2015[i] - t_me_2015[i]) / base_sim[i])
lp_actual.append(t_mg_actual[i] / t_me_actual[i])
arp_actual.append((t_mg_actual[i] - t_me_actual[i]) / base_sim[i])
In [143]:
# ---------------------------------------------------------------------------------
# VISUALIZAR LOS RESULTADOS PROGRESIVIDAD 2015:
# ---------------------------------------------------------------------------------
def ver_calculos_prog():
print "{0:^80}".format("ANALISIS DE PROGRESIVIDAD, MUESTRA FILTRADA")
print "{0:<80}".format("="*78)
print "{0:>10}\t{1:^10}\t{2:>10}\t{3:10}\t{4:10}".format("Base", "LP_14", "LP_15", "ARP_14 * 10^6", "ARP_15 * 10^6")
print "{0:10}\t{0:10}\t{0:10}\t{0:10}\t{0:10}".format("-"*10)
for i in range(0, len(base_sim), 500):
print "{0:>10.0f}\t{1:^10.3f}\t{2:10.3f}\t{3:10.5f}\t{4:10.4f}".format(base_sim[i], round(t_mg_2015[i], 4),
round(t_me_2015[i], 3), lp_actual[i], LP_2015[i], 1000000 * arp_actual[i], 1000000 * ARP_2015[i])
print "{0:<80}".format("="*78)
ver_calculos_prog()
In [144]:
def graf_indices_lp_arp():
plt.figure("indices", figsize=(15,8), dpi=900)
plt.suptitle(u"Índice de Progresividad: LP y ARP", fontsize=15)
plt.subplot(2,1,1)
plt.plot(base_sim, arp_actual, label = "ARP 2014", linewidth=2.0)
plt.plot(base_sim, ARP_2015, label = "ARP 2015", linewidth=2.0)
plt.fill_between(base_sim, arp_actual, ARP_2015, color = 'black', interpolate = True, alpha = 0.03)
plt.legend()
plt.margins(0.01)
plt.xticks(np.arange(0, 400000, 20000))
plt.ylabel(u"Valor del índice")
plt.xlabel("Base")
plt.subplot(2,1,2)
plt.plot(base_sim, lp_actual, label = "LP 2014", linewidth=2.0)
plt.plot(base_sim, LP_2015, label = "LP 2015", linewidth=2.0)
plt.fill_between(base_sim, lp_actual, LP_2015, color = 'black', interpolate = True, alpha=0.03)
plt.legend()
plt.ylabel(u"Valor del índice")
plt.xlabel("Base")
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
# plt.xlim(0,310000)
plt.show
graf_indices_lp_arp()
In [145]:
# CALCULO DE GANANCIA O PERDIDA DE PROGRESIVIDAD CON LOS INDICES LP Y ARP NORMALIZADOS
def graf_prog_1():
inc_arp = []
inc_lp = []
for i in range(len(base_sim)):
try:
inc_arp.append(float(((ARP_2015[i] / arp_actual[i]) - 1) * 100))
inc_lp.append((float((LP_2015[i] / lp_actual[i]) - 1) * 100))
except:
inc_arp.append(0)
inc_lp.append(0)
plt.figure("prog_relativa", figsize = (15,4), dpi = 900)
plt.suptitle("INCREMENTO DE PROGRESIVIDAD RESPECTO DE 2014", fontsize=15)
plt.plot(base_sim, inc_lp, label = "Progresividad relativa LP", linewidth=2)
plt.plot(base_sim, inc_arp, label = "Progresividad relativa ARP", linewidth=2)
plt.fill_between(base_sim, inc_lp, 0, color = "b", alpha = 0.1,)
plt.fill_between(base_sim, inc_arp, 0, color = "g", alpha = 0.1,)
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.xlabel("Base", fontsize=14)
plt.ylabel("Incremento relativo (%)", fontsize=14)
plt.legend()
graf_prog_1()
In [146]:
# ---------------------------------------------------------------------------------
# GRAFICO DEL INDICE LP 2014 2015
# ---------------------------------------------------------------------------------
plt.figure(dpi=900)
plt.suptitle(u'ANÁLISIS DE PROGRESIVIDAD', fontsize=14)
plt.subplot(2,2,3) # Divide en dos el lienzo por la vertical primer 2 y segundo 2 por la horizontal
plt.plot(base_sim, lp_actual, label = u"Índice LP_2014")
# plt.scatter(base_sim, lp_actual) # añade los puntos en cada base
plt.xlabel("Base")
plt.ylabel("Valor del indice")
plt.margins(0.01)
plt.legend()
plt.subplot(2,2,4)
plt.plot(base_sim, LP_2015, label = "LP_2015")
# plt.scatter(base_sim, LP_2015)
plt.xlabel("Base")
plt.ylabel("Valor del indice")
plt.margins(0.01) # AGREGA UN MARGEN PARA VISUALIZAR EL GRÁFICO COMPLETO EN LOS LIMITES
plt.legend()
# ---------------------------------------------------------------------------------
# GRAFICO INDICE ARP 2014 2015
# ---------------------------------------------------------------------------------
plt.subplot(2,2,1)
plt.plot(base_sim, arp_actual, label = u"Índice ARP_2014")
# plt.scatter(base_sim, arp_actual, label = "ARP 2014")
plt.margins(0.01) # AGREGA UN MARGEN PARA VISUALIZAR EL GRÁFICO COMPLETO EN LOS LIMITES
plt.xlabel("Base")
plt.ylabel("Valor del indice")
plt.legend()
plt.subplot(2,2,2)
plt.plot(base_sim, ARP_2015, label = u"Índice ARP_2015")
# plt.scatter(base_sim, ARP_2015, label = "ARP 2015")
plt.legend()
plt.xlabel("Base")
plt.ylabel("Valor del indice")
plt.margins(0.01)
plt.show()
In [147]:
from tabular_csv import *
declarantes = tabular_csv("distribución_declarantes.csv", ";") # imprime una muestra de comprobacion, intervalo de base imp
cols_declarantes = []
for i in range(len(declarantes)):
cols_declarantes.append(declarantes[i].pop(0).decode("utf-8"))
In [147]:
In [147]:
In [148]:
print cols_declarantes
In [149]:
declarantes[1] = map(lambda x: float(x), declarantes[1])
declarantes[0] = declarantes[0][1:-1]
declarantes[1] = declarantes[1][1:-1]
aux_int = [elem.split("-") for elem in declarantes[0]]
for f,a in enumerate(aux_int):
for e,aa in enumerate(aux_int[f]):
aux_int[f][e] = float(aux_int[f][e])
marca_clase_bi = []
for i in aux_int:
marca_clase_bi.append(np.mean(i))
base_sim_pond = marca_clase_bi
In [150]:
print "{:^55}".format("RESUMEN: DISTRUBUCIÓN DE DECLARANTES")
print "{:^50}".format("=" * 50)
print "{:^15}\t{:^15}\t{:^15}".format("intervalo bi", "marca de clase", "frec. declarantes")
print "{:^15}\t{:^15}\t{:^15}".format("-" * 14, "-" * 14, "-" * 14)
for i,e in enumerate(declarantes[0]):
print "{:^15}\t{:^15.0f}\t{:^15.0f}".format(declarantes[0][i], marca_clase_bi[i], declarantes[1][i])
print "{:^50}".format("=" * 50)
In [151]:
def graf_declarantes():
plt.figure(figsize=(15,4), dpi=800)
plt.suptitle("Distribucion de declarantes por tramo de base")
plt.plot(marca_clase_bi, declarantes[1], label="Numero de declarantes", linewidth=3)
plt.xlabel("BASE")
plt.ylabel("DECLARANTES")
plt.fill_between(marca_clase_bi, declarantes[1], 0, color="b", alpha=0.07)
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.legend()
plt.show()
graf_declarantes()
In [169]:
In [153]:
# DECLARAMOS LAS INCOGNITAS PARA PONDERAR CON LOS DATOS DE DECLARANTES:
t_me_ac_pond = []
t_mg_ac_pond = []
ci_ac_pond = []
ci_2015_pond = []
t_me_2015_pond = []
t_mg_2015_pond = []
In [154]:
comp_actual_pond = [[base_sim_pond[i] <= base_actual[ii] for ii in range(len(base_actual))] for i in range(len(base_sim_pond))] # hayar el intervalo
ind_actual_pond = [] # agregamos el intervalo correspondiente
for i in range(len(base_sim_pond)):
if True in comp_actual_pond[i]:
ind_actual_pond.append(comp_actual_pond[i].index(True) - 1)
else:
ind_actual_pond.append(len(base_actual) - 1)
for i in range(len(base_sim_pond)):
ci_ac_pond.append(cuota_actual[ind_actual_pond[i]] + (base_sim_pond[i] - base_actual[ind_actual_pond[i]]) * t_actual[ind_actual_pond[i]])
t_mg_ac_pond.append(t_actual[ind_actual_pond[i]])
t_me_ac_pond.append(ci_actual[i] / base_sim_pond[i])
####################################################################################
# 2015: CALCULOS CUOTAS, TIPO MARGINAL Y TIPO MEDIO TRAS LA REFORMA 2015 #
####################################################################################
comp_2015_pond = [[base_sim_pond[i] <= base_2015[ii] for ii in range(len(base_2015))] for i in range(len(base_sim_pond))]
ind_2015_pond = []
for i in range(len(base_sim_pond)):
if True in comp_2015_pond[i]:
ind_2015_pond.append(comp_2015_pond[i].index(True) - 1)
else:
ind_2015_pond.append(len(base_2015) - 1)
for i in range(len(base_sim_pond)):
ci_2015_pond.append(cuota_2015[ind_2015_pond[i]] + (base_sim_pond[i] - base_2015[ind_2015_pond[i]]) * t_2015[ind_2015_pond[i]])
t_mg_2015_pond.append(t_2015[ind_2015_pond[i]])
t_me_2015_pond.append(ci_2015[i] / base_sim_pond[i])
In [155]:
####################################################################################
###### PRESENTACION DE DATOS VISUALES #########
####################################################################################
# ---------------------------------------------------------------------------------
# CALCULOS ACTUAL:
# ---------------------------------------------------------------------------------
def ver_calculos_ac_pond():
print "{:^60}".format("CALCULOS IRPF 2014 PARA ARAGON")
print "{:^60}".format("=" * 60)
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("Clase: BI", "Cuota", "tmg", "tme")
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("-" * 10, "-" * 10, "-" * 10, "-" * 10)
for i in range(len(base_sim_pond)):
print "{:^10.0f}\t{:^10.2f}\t{:^10.4f}\t{:^10.4f}".format(base_sim_pond[i], ci_ac_pond[i], t_mg_ac_pond[i], t_me_ac_pond[i])
print "{:^60}".format("=" * 60)
ver_calculos_ac_pond()
In [155]:
In [156]:
# ---------------------------------------------------------------------------------
# VISUALIZAR LOS RESULTADOS IRPF 2015:
# ---------------------------------------------------------------------------------
def ver_calculos_2015_pond():
print "{:^60}".format("RESULTADO CALCULOS IRPF 2015")
print "{:^60}".format("=" * 60)
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("Clase: BI", "Cuota", "tmg", "tme")
print "{:^10}\t{:^10}\t{:^10}\t{:^10}".format("-" * 10, "-" * 10, "-" * 10, "-" * 10)
for i in range(len(base_sim_pond)):
print "{:^10.0f}\t{:^10.2f}\t{:^10.4f}\t{:^10.4f}".format(base_sim_pond[i], ci_2015_pond[i], t_mg_2015_pond[i], t_me_2015_pond[i])
print "{:^60}".format("=" * 60)
ver_calculos_2015_pond()
In [157]:
ci_ac_pond = np.multiply(ci_ac_pond, declarantes[1])
ci_2015_pond = np.multiply(ci_2015_pond, declarantes[1])
In [158]:
# faltan los tipos medios ponderados:
In [159]:
print "{:^35}".format("Cuota por numero de declarantes")
print "{:^35}".format("(unidades x 10^6)")
print "{:^35}".format("=" * 35)
print "{:^15}\t{:^15}".format("2014", "2015")
print "{:^15}\t{:^15}".format("-" * 15, "-" * 15)
for e,ee in enumerate(ci_2015_pond):
print "{:^15.4f}\t{:^15.2f}".format(ci_ac_pond[e] / 10 ** 6, ee / 10 ** 6)
print "{:^35}".format("=" * 35)
In [160]:
plt.figure("cuotas_ponderadas", figsize=(15,7), dpi=800)
plt.suptitle("CUOTA ABSOLUTA", fontsize=15)
plt.plot(base_sim_pond, ci_ac_pond, label="cuota_total_2014")
plt.plot(base_sim_pond, ci_2015_pond, label="cuota_total_2015")
plt.fill_between(base_sim_pond, ci_ac_pond, 0, color="b", alpha=0.07)
plt.fill_between(base_sim_pond, ci_2015_pond, 0, color="g", alpha=0.07)
plt.margins(0.01)
plt.xlabel("BASE")
plt.ylabel("VOLUMEN DE CUOTA")
plt.xticks(range(0,int(base_sim_pond[-1]), 25000))
plt.axhline(y=np.mean(ci_ac_pond), alpha=0.5, label="Media CI 2014")
plt.axhline(y=np.mean(ci_2015_pond), color="g", alpha=0.5, label="Media CI 2015")
plt.legend()
Out[160]:
In [170]:
def graf_recaudacion():
var_cuota_pond = np.divide(ci_2015_pond, ci_ac_pond) - 1
plt.figure(figsize=(15,8), dpi=800)
plt.subplot(2,1,1)
plt.suptitle("CUOTA ABSOLUTA", fontsize=15)
plt.plot(base_sim_pond, ci_ac_pond, label="cuota_total_2014")
plt.plot(base_sim_pond, ci_2015_pond, label="cuota_total_2015")
plt.fill_between(base_sim_pond, ci_ac_pond, 0, color="b", alpha=0.07)
plt.fill_between(base_sim_pond, ci_2015_pond, 0, color="g", alpha=0.07)
plt.legend()
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.xlabel("BASE")
plt.ylabel("VOLUMEN DE CUOTA")
plt.subplot(2,1,2)
plt.suptitle("VARIACION RELATIVA ENTRE NORMATIVA 2014-2015", fontsize=15)
plt.plot(base_sim_pond, var_cuota_pond * 100, label="variacion de la cuota")
plt.legend()
plt.xlabel("BASE")
plt.ylabel("VARIACION DE LA CUOTA (%)")
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.fill_between(base_sim_pond, var_cuota_pond * 100, 0, color="b", alpha=0.07)
graf_recaudacion()
In [162]:
# faltan los marginales de la renta ponderada
#
In [163]:
lp_actual_pond = []
arp_actual_pond = []
LP_2015_pond = [] # indice LP_2015
ARP_2015_pond = [] # indice ARP_2015
for i in range(len(base_sim_pond)):
LP_2015_pond.append(t_mg_2015_pond[i] / t_me_2015_pond[i])
ARP_2015_pond.append((t_mg_2015_pond[i] - t_me_2015_pond[i]) / base_sim_pond[i])
lp_actual_pond.append(t_mg_ac_pond[i] / t_me_ac_pond[i])
arp_actual_pond.append((t_mg_ac_pond[i] - t_me_ac_pond[i]) / base_sim[i])
In [171]:
def graf_prog_recaudacion():
plt.figure(figsize=(15,8), dpi=800)
plt.subplot(2,1,1)
plt.plot(base_sim_pond, lp_actual_pond, linewidth=2, label="LP 2014")
plt.plot(base_sim_pond, LP_2015_pond, linewidth=2, label="LP 2015")
plt.fill_between(base_sim_pond, lp_actual_pond, 0, color="b", alpha=0.09)
plt.fill_between(base_sim_pond, LP_2015_pond, 0, color="g", alpha=0.09)
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.legend()
plt.subplot(2,1,2)
plt.suptitle("INDICE LP Y ARP")
plt.plot(base_sim_pond, arp_actual_pond, linewidth=2, label="ARP 2014")
plt.plot(base_sim_pond, ARP_2015_pond, linewidth=2, label="ARP 2015")
plt.fill_between(base_sim_pond, arp_actual_pond, 0, color="b", alpha=0.09)
plt.fill_between(base_sim_pond, ARP_2015_pond, 0, color="g", alpha=0.09)
plt.xticks(np.arange(0, 400000, 20000))
plt.xlim(0,400000)
plt.legend()
graf_prog_recaudacion()
In [172]:
graf_declarantes()
graf_indices_lp_arp()
graf_prog_1()
graf_recaudacion()
graf_prog_recaudacion()
In [165]:
# LP_15 = LP_14 = tmg_15* / tme_15
In [165]:
In [165]: