@fanxy 2016-09-27T09:35:01.000000Z 字数 3291 阅读 1265

# 第四讲 地方政府债务：改革、发展与案例分析

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

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:\\")    # 设定工作目录

# 1. 土地出让收入

total=read_excel("../Ch03/Ch03_Data.xls",sheet="total",skip=1)local_inc=total%>%  mutate(year=as.numeric(year(指标名称)))%>%  mutate(local_inc=国家财政收入*(100-中央财政收入:占比)/100)%>%  select(year,local_inc)land=read_excel("Ch04_Data.xlsx",sheet="land") str(land)land=land%>%  filter(单位 %in% c("万元") & !grepl('招拍挂|协议',指标名称))%>%  select(-单位,-指标ID)%>%  rename(region=指标名称)%>%  gather(year,value,-region)%>%  mutate(year=as.numeric(year))%>%  filter(!is.na(value))%>%  mutate(value=value/10000)%>%  mutate(region=sub("土地出让成交价款:","",region))%>%  left_join(local_inc,by="year")%>%  mutate(land2inc=ifelse(region=="全国",value/local_inc,NA))%>%  select(-local_inc)%>%  arrange(year,value)g_land=land[land$region=="全国",]twoord.plot(lx = g_land$year, ly = g_land$value,  rx = g_land$year,  ry = g_land$land2inc,  main = '土地财政', xlab = '',  ylab = '土地出让收入（万元）', rylab = '占地方财政收入之比',  type = c('line','line')) ggplot(land[!land$region %in% c("全国","西藏"),],aes(year,value)) +  geom_line()+facet_wrap(~region,ncol=5)+  labs(title = "各地区土地出让收入（万元）",x="",y="")+  theme_bw()

# 2. 地方债发行月度数据

debt_mm=read_excel("Ch04_Data.xlsx",sheet="debt_mm",col_types=c("date",rep("numeric",5)))debt_mm=debt_mm%>%  mutate(time=as.Date(日期))%>%  select(-日期,-总计)%>%  gather(var,value,-time)%>%  filter(!is.na(value))ggplot(debt_mm,aes(time,value,fill=var))+  geom_bar(stat="identity")+  labs(title="地方债发行：按类别分月度数据",x="",y="")+  guides(fill=guide_legend(title=NULL))+  theme_bw()+theme(legend.position="bottom")

# 3. 地方债利率

cen_loc=read_excel("Ch04_Data.xlsx",sheet="cen_loc",skip=1) str(cen_loc)cen_loc=cen_loc%>%  rename(time=指标名称)%>%  gather(var,i,-time)%>%  filter(!is.na(i))%>%  mutate(type=substr(var,5,6))%>%  mutate(type=ifelse(type=="地方","地方债",type))%>%  mutate(term=sub(".*:","",var))%>%  select(-var)ggplot(cen_loc,aes(time,i,color=type))+geom_point()+geom_smooth()+  facet_wrap(~term,ncol=3)+labs(title="不同期限地方债和国债发行利率",x="",y="")+        guides(color = guide_legend(title = NULL)) +         theme_bw()+ theme(legend.position = 'bottom') 

# 4. 城投债利率

cityinv=read_excel("Ch04_Data.xlsx",sheet="cityinv",skip=1,                   col_types=c("date",rep("numeric",226)))    str(cityinv)cityinv=cityinv%>%  rename(time=指标名称)%>%  gather(var,i,-time)%>%  filter(!is.na(i))%>%   mutate(market=substr(var,1,2))%>%  mutate(type=sub(".*城投债","",var))%>%  mutate(type=sub("收益率.*","",type))%>%  mutate(grade=sub(".*\$","",var))%>% mutate(grade=sub("\$.*","",grade))%>%  mutate(term=sub(".*:","",var))%>%  select(-var)# 查看数据summary(cityinv$time[cityinv$market=="银行"]) # 银行间市场从2012-01-09开始summary(cityinv$time[cityinv$market=="中债"]) # 中债从2008-08-13开始table(cityinv$market,cityinv$grade)           # 中债评级有AAAtable(cityinv$market,cityinv$type)            # 银行间有远期收益率table(cityinv$market,cityinv$term)            # 中债6个月标记为0年，银行间没有9年g=cityinv%>%  filter(market=="中债" & type=="到期" &            grade %in% c("AA-","AAA") & term %in% c("1年","3年","10年"))ggplot(g,aes(time,i,color=term))+geom_line()+facet_wrap(~grade,ncol=2)+  labs(title="中债城投债到期收益率",x="",y="")+  guides(color=guide_legend(title=NULL))+  theme_bw()+theme(legend.position="bottom")

• 私有
• 公开
• 删除