@fanxy 2016-09-19T20:20:14.000000Z 字数 8321 阅读 1740

# 第三讲 财税体制改革与“营改增”

樊潇彦 复旦大学经济学院 中级宏观

# 准备工作install.packages("readxl")    # 读取excel数据install.packages("stringr")   # 处理字符串install.packages("corrplot")  # 作相关关系图install.packages("igraph")    # 作网络图install.packages("forecast")  # 作季节调整library(readxl)               # 读取excel数据library(stringr)              # 字符串处理library(corrplot)library(igraph)library(forecast) library(stats)                # 基础包，不用安装直接调用library(dplyr)library(tidyr)library(data.table)  library(foreign)library(readstata13)library(haven)   library(ggplot2)library(ggrepel)library(dygraphs)     library(plotrix)      library(lubridate)    library(zoo)          library(mFilter)      setwd("D:\\...")              # 设定工作目录rm(list=ls())

# 1. 财政发展与变迁

total=read_excel("Ch03_Data.xls",sheet="total", skip=1,                col_names=T,col_types=c("date",rep("numeric",4)))gdp=read_excel("../Ch02/Ch02_Data.xlsx",col_names=T,sheet="gdp_idx")gdp=gdp%>%filter(!is.na(year))%>%select(year,GDP)tax_str=total%>%  mutate(year=year(指标名称))%>%  left_join(gdp,by="year")%>%  mutate(国家财政收入/GDP=国家财政收入/GDP)%>%  mutate(国家财政赤字/GDP=(国家财政收入-国家财政支出)/GDP)%>%  select(year,国家财政收入/GDP,国家财政赤字/GDP,中央财政收入:占比,中央财政支出:占比)%>%  arrange(year)%>%  gather(var,share,-year)%>%  filter(!is.na(share))ggplot(tax_str[tax_str$var %in% c("国家财政收入/GDP","国家财政赤字/GDP"),], aes(year,share,color=var))+geom_line(size=1)+ geom_vline(xintercept=1958,linetype = "dotdash",col="black")+ geom_vline(xintercept=1978,linetype = "dotdash",col="black")+ geom_vline(xintercept=1984,linetype = "dotdash",col="black")+ geom_vline(xintercept=1994,linetype = "dotdash",col="red")+ labs(title="国家财政收入与赤字占GDP的比重",x="",y="")+  scale_x_continuous(breaks = c(1952, 1958, 1978, 1984, 1994, 2015))+ guides(color = guide_legend(title = NULL)) +  theme_bw()+ theme(legend.position = 'bottom') ggplot(tax_str[tax_str$var %in% c("中央财政收入:占比","中央财政支出:占比"),],       aes(year,share,color=var))+geom_line(size=1)+       geom_vline(xintercept=1958,linetype = "dotdash",col="black")+       geom_vline(xintercept=1978,linetype = "dotdash",col="black")+       geom_vline(xintercept=1984,linetype = "dotdash",col="black")+       geom_vline(xintercept=1994,linetype = "dotdash",col="red")+       labs(title="中央财政收入和支出占比（%）",x="",y="")+        scale_x_continuous(breaks = c(1952, 1958, 1978, 1984, 1994, 2015))+       guides(color = guide_legend(title = NULL)) +         theme_bw()+ theme(legend.position = 'bottom') 

# 2. 各级财政税收收入占比

class=read_excel("Ch03_Data.xls",sheet="class",               col_names=T,col_types=c(rep("text",2),rep("numeric",66)))colnames(class)=c("varid","var",1950:2015)class_var=class[,c(1,2)]class=class%>%  select(-varid)%>%  gather(year,value,-var)%>%  filter(!is.na(value))%>%  mutate(year=as.numeric(year))%>%  mutate(level=substr(var,1,2))%>%  mutate(item=sub(".*:","",var))%>%  mutate(var=sub(".*公共财政支出.*","公共财政支出",var))%>%  mutate(var=sub(".*公共财政收入:税收收入.*","公共财政收入:税收",var))%>%  mutate(var=sub(".*公共财政收入:非税收收入.*","公共财政收入:非税收",var))%>%  mutate(item=sub("事务","",item))%>%  mutate(item=sub("医疗卫生与计划生育","医卫计生",item))%>%  mutate(item=sub("社会保障和就业","社保就业",item))%>%  arrange(level, var, item, year)inc_str=class%>%  filter((var=="公共财政收入:非税收" | var=="公共财政收入:税收") &           item!="合计" & year>=2007)%>%  group_by(year,level, var)%>%  summarise(total_inc=sum(value))%>%  spread(var,total_inc)%>%  mutate(tax_share=公共财政收入:税收/(公共财政收入:税收+公共财政收入:非税收))ggplot(inc_str,aes(year,tax_share,color=level))+geom_line(size=1)+  labs(title="各级财政税收收入占比",x="",y="")+  guides(color=guide_legend(title=NULL))+  theme_bw()+theme(legend.position="bottom")

• 私有
• 公开
• 删除