[关闭]
@fanxy 2016-10-09T08:30:42.000000Z 字数 9815 阅读 1097

第五讲 国有企业改革

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


  1. library(readxl) # 读取excel数据
  2. library(stringr) # 字符串处理
  3. library(corrplot)
  4. library(igraph)
  5. library(forecast)
  6. library(stats) # 基础包,不用安装直接调用
  7. library(dplyr)
  8. library(tidyr)
  9. library(data.table)
  10. library(foreign)
  11. library(readstata13)
  12. library(haven)
  13. library(ggplot2)
  14. library(ggrepel)
  15. library(dygraphs)
  16. library(plotrix)
  17. library(lubridate)
  18. library(zoo)
  19. library(mFilter)
  20. setwd("D:\\") # 设定工作目录

1. 国有企业概况

1.1 财政部数据

  1. cz=read_excel("Ch05_Data.xlsx",sheet="财政部")
  2. colnames(cz)=c("unit","var",seq(1995,2014))
  3. # 规模
  4. g_scale=cz%>%
  5. select(-unit)%>%
  6. filter(var %in% c("汇编企业户数","汇编企业户数:中央企业","汇编企业户数:地方企业",
  7. "所有者权益总额","所有者权益总额:中央","所有者权益总额:地方"))%>%
  8. mutate(level=ifelse(regexpr("中央",var)>0,"中央",ifelse(regexpr("地方",var)>0,"地方","全部")))%>%
  9. mutate(var=sub(":.*","",var))%>%
  10. mutate(var=ifelse(var=="所有者权益总额","所有者权益总额(万亿元)","汇编企业户数(万户)"))%>%
  11. gather(year,value,-var,-level)%>%
  12. mutate(year=as.numeric(year))%>%
  13. mutate(value=ifelse(var=="所有者权益总额(万亿元)",value/10000,value))%>%
  14. filter(!is.na(value))%>%
  15. arrange(var,level,year)
  16. ggplot(g_scale,aes(year,value,color=level))+geom_line(size=1)+facet_wrap(~var)+
  17. labs(title="全国国有企业:规模",x="",y="")+
  18. scale_x_continuous(breaks = c(1997, 2003, 2008, 2014))+
  19. guides(color=guide_legend(title=NULL))+theme_bw()+theme(legend.position="bottom")
  20. # 盈利
  21. g_prof=cz%>%
  22. select(-unit)%>%
  23. filter(var %in% c("总资产报酬率","净资产利润率","销售利润率"))%>%
  24. gather(year,value,-var)%>%
  25. mutate(year=as.numeric(year))%>%
  26. filter(!is.na(value))%>%
  27. arrange(var,year)
  28. ggplot(g_prof,aes(year,value,color=var))+geom_line(size=1)+
  29. labs(title="全国国有企业:盈利",x="",y="")+
  30. scale_x_continuous(breaks = c(1997, 2003, 2008, 2014))+
  31. guides(color=guide_legend(title=NULL))+theme_bw()+theme(legend.position="bottom")
  32. # 负债
  33. g_risk=cz%>%
  34. select(-unit)%>%
  35. filter(var %in% c("资产总额","资产总额:中央企业","资产总额:地方企业",
  36. "负债总额","负债总额:中央","负债总额:地方",
  37. "所有者权益总额","所有者权益总额:中央","所有者权益总额:地方"))%>%
  38. gather(year,value,-var)%>%
  39. mutate(year=as.numeric(year))%>%
  40. filter(!is.na(value))%>%
  41. mutate(level=ifelse(regexpr("中央",var)>0,"中央",ifelse(regexpr("地方",var)>0,"地方","全部")))%>%
  42. mutate(var=sub(":.*","",var))%>%
  43. spread(var,value)%>%
  44. mutate(`杠杆率`=`负债总额`/`所有者权益总额`)%>%
  45. mutate(`资产负债率`=`负债总额`/`资产总额`)%>%
  46. select(year,level,`杠杆率`,`资产负债率`)%>%
  47. gather(var,value,-year,-level)
  48. ggplot(g_risk,aes(year,value,color=level))+geom_line(size=1)+facet_free(~var)+
  49. labs(title="全国国有企业:债务",x="",y="")+
  50. scale_x_continuous(breaks = c(1997, 2003, 2008, 2014))+
  51. guides(color=guide_legend(title=NULL))+theme_bw()+theme(legend.position="bottom")

1.2 国资委数据

  1. gz=read_excel("Ch05_Data.xlsx",sheet="国资委")
  2. colnames(gz)=c("unit","var",seq(2005,2014))
  3. gz=gz%>%
  4. select(-unit)%>%
  5. mutate(group=sub(".*:","",var))%>%
  6. mutate(var=sub(":.*","",var))%>%
  7. gather(year,value,-var,-group)%>%
  8. mutate(year=as.numeric(year))%>%
  9. filter(!is.na(value))%>%
  10. spread(var,value)%>%
  11. mutate(`杠杆率`=`资产负债率`/(100-`资产负债率`))%>%
  12. mutate(gtype=ifelse(group %in% c("大型企业","中型企业","小型企业"),"规模",""))%>%
  13. mutate(gtype=ifelse(group %in% c("国资委系统监管企业","政府部门管理企业","地方企业"),"央地",gtype))%>%
  14. mutate(gtype=ifelse(group %in% c("东部沿海地区","中部内陆地区","西部边远地区"),"区域",gtype))%>%
  15. mutate(gtype=ifelse(group %in% c("盈利企业","亏损企业"),"盈亏",gtype))%>%
  16. filter(group!="中央企业" & !(year==2014 & gtype=="央地"))%>%
  17. group_by(year,gtype)%>%
  18. mutate(`净资产占比`=`所有者权益(净资产)`/sum(`所有者权益(净资产)`))%>%
  19. mutate(color=ifelse(group %in% c("大型企业","国资委系统监管企业","东部沿海地区","盈利企业"),"1","2"))%>%
  20. mutate(color=ifelse(group %in% c("小型企业","地方企业","西部边远地区"),"3", color))%>%
  21. mutate(label=ifelse(year==2009,group,""))
  22. ggplot(gz,aes(year,`净资产占比`,color=color))+geom_line(size=1)+facet_wrap(~gtype)+
  23. scale_x_continuous(breaks = c(2005, 2008, 2014))+
  24. labs(title="不同组别净资产占比",x="",y="")+geom_text(aes(label=label))+
  25. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")
  26. ggplot(gz,aes(year,`杠杆率`,color=color))+geom_line(size=1)+facet_wrap(~gtype)+
  27. scale_x_continuous(breaks = c(2005, 2008, 2014))+
  28. labs(title="不同组别杠杆率比较",x="",y="")+geom_text(aes(label=label))+
  29. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")

2. 国有企业概况:按行业和工业行业分

  1. # 行业及代码
  2. ind=data.frame(indno=1:13,ind=c("农林牧渔业","工业","建筑业","地质勘查及水利业","交通运输仓储业",
  3. "邮电通信业","批发和零售、餐饮业","房地产业","信息技术服务业","社会服务业",
  4. "卫生体育福利业","教育文化广播业","科学研究和技术服务业"))
  5. ind$indno=factor(ind$ind,ordered=is.ordered(ind$indno))
  6. ind$ind=as.character(ind$ind)
  7. ind_m=cz%>%
  8. select(var)%>%
  9. filter(substring(var,nchar(var)-1)=="工业")%>%
  10. mutate(var=sub(".*工业:","",var))%>%
  11. mutate(var=sub(".*:工业|汽车工业",NA,var))%>%
  12. filter(!is.na(var))
  13. ind_m=data.frame(indno=201:215,ind=unique(ind_m$var))
  14. ind_m$indno=factor(ind_m$ind,ordered=is.ordered(ind_m$indno))
  15. ind_m$ind=as.character(ind_m$ind)
  16. ind_cz=cz%>%
  17. select(-unit)%>%
  18. filter(substring(var,nchar(var))=="业" & substring(var,nchar(var)-1)!="企业") %>%
  19. mutate(ind=sub(".*:","",var))%>%
  20. mutate(var=sub(":.*","",var))%>%
  21. gather(year,value,-var,-ind)%>%
  22. mutate(year=as.numeric(year))%>%
  23. filter(!is.na(value)) %>%
  24. spread(var,value)
  25. # 行业规模占比
  26. g_ind_scale=merge(ind_cz,ind,by="ind")
  27. g_ind_scale=g_ind_scale%>%
  28. group_by(year)%>%
  29. mutate(`职工人数占比`=`职工人数`/sum(`职工人数`))%>%
  30. mutate(`所有者权益占比`=`所有者权益总额`/sum(`所有者权益总额`))%>%
  31. select(year,indno,`职工人数占比`,`所有者权益占比`)%>%
  32. gather(var,value,-year,-indno)%>%
  33. group_by(year,var)%>%
  34. mutate(rk=n()+1-min_rank(value))%>%
  35. filter(year %in% c(1995,2003,2014))%>%
  36. arrange(year,indno)
  37. ggplot(g_ind_scale[g_ind_scale$rk<=5,],aes(rk,value,fill=indno))+facet_grid(var~year)+
  38. geom_bar(stat="identity", position="dodge")+
  39. labs(title="国企规模:按行业分",x="",y="")+geom_text(aes(label=indno))+
  40. guides(fill=guide_legend(title=NULL))+theme_bw()+theme(legend.position="non")
  41. # 工业规模占比
  42. g_m_scale=merge(ind_cz,ind_m,by="ind")
  43. g_m_scale=g_m_scale%>%
  44. group_by(year)%>%
  45. mutate(`职工人数占比`=`职工人数`/sum(`职工人数`))%>%
  46. mutate(`所有者权益占比`=`所有者权益总额`/sum(`所有者权益总额`))%>%
  47. select(year,indno,`职工人数占比`,`所有者权益占比`)%>%
  48. gather(var,value,-year,-indno)%>%
  49. group_by(year,var)%>%
  50. mutate(rk=n()+1-min_rank(value))%>%
  51. filter(year %in% c(1995,2003,2014))%>%
  52. arrange(year,indno)
  53. ggplot(g_m_scale[g_m_scale$rk<=5,],aes(rk,value,fill=indno))+facet_grid(var~year)+
  54. geom_bar(stat="identity", position="dodge")+
  55. labs(title="国企规模:按工业行业分",x="",y="")+geom_text(aes(label=indno))+
  56. guides(fill=guide_legend(title=NULL))+theme_bw()+theme(legend.position="non")
  57. # 行业财务状况
  58. g_ind_prof=merge(ind_cz,ind,by="ind")
  59. g_ind_prof=g_ind_prof%>%
  60. mutate(`利税/总资产`=(`利润总额`+`上交税金总额`)/`资产总额`)%>%
  61. mutate(`利税/所有者权益`=(`利润总额`+`上交税金总额`)/`所有者权益总额`)%>%
  62. mutate(`人均利税`=(`利润总额`+`上交税金总额`)/`职工人数`)%>%
  63. mutate(`杠杆率`=`负债合计`/`所有者权益总额`)%>%
  64. mutate(`资产负债率`=`负债合计`/`资产总额`)%>%
  65. select(year,indno,`利税/总资产`:`资产负债率`) %>%
  66. gather(var,value,-year,-indno)%>%
  67. filter(!is.na(value))%>%
  68. group_by(year,var)%>%
  69. mutate(rk=n()+1-min_rank(value))%>%
  70. filter(year %in% c(2003,2014))
  71. ggplot(g_ind_prof[g_ind_prof$var %in% c("利税/总资产","利税/所有者权益","人均利税") &
  72. g_ind_prof$rk<=5,],aes(rk,value,fill=indno))+facet_free(var~year)+
  73. geom_bar(stat="identity", position="dodge")+
  74. labs(title="国企盈利能力:按行业分",x="",y="")+
  75. geom_text(aes(label=indno,vjust = 1.2, angle = 10))+
  76. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")
  77. ggplot(g_ind_prof[g_ind_prof$var %in% c("杠杆率","资产负债率") &
  78. g_ind_prof$rk<=5,],aes(rk,value,fill=indno))+facet_free(var~year)+
  79. geom_bar(stat="identity", position="dodge")+
  80. labs(title="国企债务负担:按行业分",x="",y="")+
  81. geom_text(aes(label=indno,vjust = 1.2, angle = 10))+
  82. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")
  83. # 工业财务状况
  84. g_m_prof=merge(ind_cz,ind_m,by="ind")
  85. g_m_prof=g_m_prof%>%
  86. mutate(`利税/总资产`=(`利润总额`+`上交税金总额`)/`资产总额`)%>%
  87. mutate(`利税/所有者权益`=(`利润总额`+`上交税金总额`)/`所有者权益总额`)%>%
  88. mutate(`人均利税`=(`利润总额`+`上交税金总额`)/`职工人数`)%>%
  89. mutate(`杠杆率`=`负债合计`/`所有者权益总额`)%>%
  90. mutate(`资产负债率`=`负债合计`/`资产总额`)%>%
  91. select(year,indno,`利税/总资产`:`资产负债率`) %>%
  92. gather(var,value,-year,-indno)%>%
  93. filter(!is.na(value))%>%
  94. group_by(year,var)%>%
  95. mutate(rk=n()+1-min_rank(value))%>%
  96. filter(year %in% c(2003,2014))
  97. ggplot(g_m_prof[g_m_prof$var %in% c("利税/总资产","利税/所有者权益","人均利税") &
  98. g_m_prof$rk<=5,],aes(rk,value,fill=indno))+facet_free(var~year)+
  99. geom_bar(stat="identity", position="dodge")+
  100. labs(title="国企盈利能力:按工业行业分",x="",y="")+
  101. geom_text(aes(label=indno))+
  102. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")
  103. ggplot(g_m_prof[g_m_prof$var %in% c("杠杆率","资产负债率") &
  104. g_m_prof$rk<=5,],aes(rk,value,fill=indno))+facet_free(var~year)+
  105. geom_bar(stat="identity", position="dodge")+
  106. labs(title="国企债务负担:按工业行业分",x="",y="")+
  107. geom_text(aes(label=indno))+
  108. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")

3. 国有资本经营收入

  1. inc=read_excel("Ch05_Data.xlsx",sheet="国有资本经营收入")
  2. colnames(inc)=c("unit","var",seq(2012,2015))
  3. inc=inc%>%
  4. select(-unit)%>%
  5. mutate(level=substr(var,1,2))%>%
  6. mutate(var=sub(".*经营收入:","",var))%>%
  7. mutate(ind=ifelse(regexpr("利润收入:",var)>0,sub("利润收入:","",var),NA))%>%
  8. mutate(var=ifelse(regexpr(":",var)<0,var,NA))
  9. total=inc%>%
  10. select(-ind,-level)%>%
  11. filter(var %in% c("地方国有资本经营收入","中央国有资本经营收入"))%>%
  12. mutate(var=substr(var,1,2))%>%
  13. gather(year,value,-var)%>%
  14. mutate(year=as.numeric(year))%>%
  15. spread(var,value)%>%
  16. mutate(`全国`=`地方`+`中央`)%>%
  17. gather(level,value,-year)
  18. ggplot(total,aes(year,value,color=level))+geom_line(size=1)+
  19. labs(title="国有资本经营收入:数额",x="",y="")+
  20. guides(color=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="bottom")
  21. share=inc%>%
  22. select(-ind)%>%
  23. filter(!is.na(var))%>%
  24. gather(year,value,-var,-level)%>%
  25. filter(!is.na(value) & !var %in% c("上年结转收入","地方国有资本经营收入","中央国有资本经营收入"))%>%
  26. group_by(year,level)%>%
  27. mutate(share=value/sum(value))%>%
  28. select(-value)
  29. ggplot(share,aes(year,share,fill=var))+geom_bar(stat="identity")+facet_wrap(~level,ncol=3)+
  30. labs(title="国有资本经营收入:来源",x="",y="")+
  31. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="bottom")
  32. prof=inc%>%
  33. select(-var)%>%
  34. filter(!is.na(ind))%>%
  35. mutate(ind=sub("企业","",ind))%>%
  36. mutate(ind=ifelse(ind=="其他国有资本经营预算","其他经营",ind))%>%
  37. gather(year,value,-ind,-level)%>%
  38. filter(!is.na(value))%>%
  39. group_by(year,level)%>%
  40. mutate(share=value/sum(value))%>%
  41. mutate(rk=n()+1-min_rank(share))%>%
  42. select(-value)%>%
  43. filter(year %in% c(2012,2015) & rk<=5)
  44. ggplot(prof,aes(rk,share,fill=ind))+facet_free(level~year)+
  45. geom_bar(stat="identity", position="dodge")+
  46. labs(title="国有资本经营收入:行业",x="",y="")+
  47. geom_text(aes(label=ind,vjust = 1.2))+
  48. guides(fill=guide_legend(title=NULL))+theme_bw()+ theme(legend.position="non")
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注