一、模型公式
式中:
r 为股权融资成本
P为股价
B为每股净资产
FROE为预测每股净资产收益率
目标:求解股权融资成本r
二、模型口径参考来源
PS:实际以代码为准
①FROE(预测每股净资产收益率):
资本市场开放与股权资本成本 2020 金融研究
②股利支付率k(综合考虑股利政策不稳定与公司规模变化、公司成长机会,采用过去3年股利支付率平均值作为k):
媒体曝光度_信息披露环境与权益资本成本 2014 金融研究
机构投资者、所有权性质与权益资本成本 2018 金融研究
终极所有权结构对权益资本成本的影响 2016 管理科学学报
贸易摩擦与权益资本成本 2021会计研究
IFRS、财务分析师、机构投资者和权益资本成本 2016会计研究
③Pt(股价)、Bt(每股净资产):二者同为t时点
资本市场开放和股权资本成本 2020 金融研究
中美交叉上市与权益资本成本研究 2013 国际金融研究
真实盈余管理与权益资本成本 2015 金融研究
④Matlab求解:
三、代码片段
3.1导入库及读取相关文件
需要的文件 1.kFlieName:股利支付率 国泰安 -> 股利政策 -> 基本数据 -> 财务指标数据 注意:
1.包含当年的过去5年 2.必须先选每股股利后选每股收益!
2.FROEFlieName:预测净资产收益率 锐思 -> 研究报告 -> 个股盈利预测
注意:1.截止日期12-31 2.需要字段:股票代码、预测年度、净资产收益率平均 3.统计时间间隔为180时数据才与wind基本一致!!!!!
3.indROEFlieName:行业ROE 锐思 -> 研究报告 -> 行业财务指标 注意:1.截止日期12-31 2.行业划分标准:9申万 3.需要字段:行业代码_IndCd、行业净资产收益率(%)_IndROE
4.closeFlieName:12月收盘价平均值 锐思 -> 股票 -> 日股票综合数据 注意:1.日期范围:12.1-12.31 2.需要字段:股票代码、日期、收盘价
5.bNewFlieName:每股净资产 锐思 -> 股票 > 年股票数据 注意:1.日期:12.31 2.需要字段:股票代码、每股净资产
6.newStkCode.csv:目标股票代码
7.RESSET_INDCLS_1.csv:公司所属行业
import pandas as pd
import numpy as np
from numpy import *
import sympy as sp
#2008
kFlieName = "2008年数据\k2003_2008.csv"
FROEFlieName = "2008年数据\RESSET_RRSTKEAFOCA_2008_1.csv"
indROEFlieName = "2008年数据\INDFI_EARNPOWER.csv"
closeFlieName = "2008年数据\RESSET_DRESSTK_2001_2010_1.csv"
bNewFlieName = "2008年数据\RESSET_YRESSTK_1.csv"
stkCode = pd.read_csv("newStkCode.csv",header=None,names=["stkCode"]) #目标股票代码
indClass = pd.read_csv("RESSET_INDCLS_1.csv",index_col="股票代码_StkCd")[["行业代码_IndCd"]]
indClass = pd.read_csv("RESSET_INDCLS_1_new.csv",index_col="股票代码_StkCd")[["行业代码_IndCd"]]
# for index,each in enumerate(indClass.index):
# indClass.index[index] = 0
newK = pd.read_csv(kFlieName,index_col="Stkcd").dropna()
FROE = pd.read_csv(FROEFlieName,index_col="股票代码_StkCd")[["预测年度_ForYear","净资产收益率平均(%)_ROEAvg"]]
FROE.columns = ["预测年度","FROE"]
# close = pd.read_csv("RESSET_MRESSTK_1.csv",index_col="股票代码_Stkcd")#.iloc[:,:-1]
# indROE = pd.read_csv(indROEFlieName,index_col="行业代码_IndCd")["行业净资产收益率(%)_IndROE"]
indROE = pd.read_csv(indROEFlieName,index_col="IndustryCode")["ROEB"]
close = pd.read_csv(closeFlieName,index_col="股票代码_Stkcd")
bNew = pd.read_csv(bNewFlieName,index_col="股票代码_Stkcd")
# indClass
# indROE
stkCodeList = set(stkCode["stkCode"])
newKIndex = set(newK.index)
FROEIndex = set(FROE.index)
indClassIndex = set(indClass.index)
indROEIndex = set(indROE.index)
closeNewIndex = set(closeNew.index)
bNewIndex = set(bNew.index)
selectIndex = stkCodeList & newKIndex & FROEIndex & bNewIndex & indClassIndex & closeNewIndex
print(len(selectIndex))
3.2股利支付率
kMean5 = []
#股利支付率k = 每股股利 / 每股收益
for eachIndex in set(newK.index):
newK.loc[eachIndex,"k"] = newK.loc[eachIndex,"T20497"]/newK.loc[eachIndex,"T60200"] #股利支付率 = 每股股利 / 每股收益
for eachIndex in sorted(list(selectIndex)):
test = newK.loc[eachIndex].iloc[:5]["k"].sum()/5 #过去5年均值
kMean5.append(test)
panel = pd.DataFrame({"k":kMean5},index=sorted(list(selectIndex)))
print(panel)
3.3FROE
FROE = FROE.loc[selectIndex]
FROE = FROE.sort_index()
for eachIndex in sorted(set(selectIndex)):
test = FROE.loc[eachIndex]
if len(test) != 3:
FROE.drop(index=[eachIndex],inplace=True,axis=0)
FROEIndex = set(FROE.index)
selectIndex = stkCodeList & newKIndex & FROEIndex & bNewIndex & indClassIndex & closeNewIndex
print(len(selectIndex))
print(len(panel))
for eachIndex in list(selectIndex):
# print(close.loc[eachIndex]["b"])
panel.loc[eachIndex,"t+1"] = FROE.loc[eachIndex].sort_values(by="预测年度")["FROE"].iloc[1]*0.01
panel.loc[eachIndex,"t+2"] = FROE.loc[eachIndex].sort_values(by="预测年度")["FROE"].iloc[2]*0.01
# close.loc[eachIndex,"t+3"] = FROE.loc[eachIndex]["FROE"].iloc[2]*0.01
panel.loc[eachIndex,"t+3"] = (panel.loc[eachIndex,"t+1"] + panel.loc[eachIndex,"t+2"])/2
panel.loc[eachIndex,"行业代码"] = indClass.loc[eachIndex][0]
print(len(panel))
for eachIndex in selectIndex:
# print(int(close.loc[eachIndex]["行业代码"]))
if int(panel.loc[eachIndex]["行业代码"]) in indROE.index:
panel.loc[eachIndex,"IndROE"] = indROE.loc[int(panel.loc[eachIndex]["行业代码"])]*0.01
print(len(panel))
for eachIndex in selectIndex:
begin = panel.loc[eachIndex,"t+3"]
end = panel.loc[eachIndex,"IndROE"]
dif = abs((begin-end)/9)#9
bFront = panel.loc[eachIndex,"b"] #b0
for i in list(range(4,13)):#13
begin = begin-dif
panel.loc[eachIndex,"t+"+str(i)] = begin
for i in list(range(1,13)):
bFront = bFront + panel.loc[eachIndex,"t+"+str(i)] * bFront * (1-panel.loc[eachIndex,"k"])
panel.loc[eachIndex,"b"+str(i)] = bFront
print(len(panel))
3.4收盘价
close = close.loc[selectIndex]
close = close.sort_index()
for eachIndex in list(selectIndex):
each = close.loc[eachIndex,"收盘价_Clpr"]
panel.loc[eachIndex,"close"] = each.mean()
print(len(panel))
3.5每股净资产
for eachIndex in list(selectIndex):
each = bNew.loc[eachIndex,"每股净资产(元/股)_NAPS"]
panel.loc[eachIndex,"b"] = each
print(len(panel))
3.6保存各年面板数据
newData = pd.read_csv("result.csv",header=None)[0].dropna() + 0.5
print(len(newData))
newData = newData[newData!=1.5]
print(len(newData))
# print(newData.sort_values()[-50:])
print(newData.sort_values()[7:-7].describe())
各年面板数据如下图:
3.7Matlab求解方程(Matlab)
clear all;clc;
data=csvread('C:\Users\zsllsz2022\Desktop\10月实证\GLS模型\core\2-原始口径合并版本-重新计算2008-2020\panel2008.csv',1,0);
P=data(:,3);
B(:,1)=data(:,4);
B(:,2:13)=data(:,19:30);
FROE(:,1:3)=data(:,5:7);
FROE(:,4:12)=data(:,10:18);
%% [-0.49995,0.49995]每隔0.0001计算函数值
for stock = 1:length(data)
for j = 1 : 10000
r(j) = 0.0001 * j;
yy(stock,j) = B(stock,1);
for i = 1 : 11
yy(stock,j) = yy(stock,j) + (FROE(stock,i)-r(j))*B(stock,i)/((1+r(j))^i);
end
yy(stock,j) = yy(stock,j) + (FROE(stock,12)-r(j))*B(stock,12)/(r(j)*(1+r(j))^12);
yy(stock,j) = yy(stock,j) - P(stock);
end
end
%% 寻找零点
for stock = 1:length(data)
count = 1;
for j = 1 : 9999
if yy(stock,j+1) * yy(stock,j) < 0
resultTemp(stock, count) = (j - 5000) * 0.0001;
count = count + 1;
end
end
end
%%
for stock = 1:length(data)
temp = 1;
for j = 1 : size(resultTemp,2)
if abs(resultTemp(stock, j)) < abs(temp) && abs(resultTemp(stock, j)) > 0.000000001
temp = resultTemp(stock, j);
end
end
result(stock,1) = temp;
end
%%
%对结果排序
xSort=sort(result);
%剔除头尾百分之一的数据
delNum=ceil(length(xSort) * 0.01);
for i=1:length(xSort)-2*delNum
x2(i,1)=xSort(i+delNum);
end
%求平均值以及标准差
avg=mean(x2);
stdev=std(x2);
% function y=myfun(r,P,B,FROE)
% F=B(1);
% for i=1:11
% F=F+(FROE(i)-r)*B(i)/((1+r)^i);
% end
% F=F+(FROE(12)-r)*B(12)/(r*(1+r)^12);
% y=P-F;
% end
四、结果
计算出的GLS模型股权融资成本(实际结果采用2种不同的GLS模型口径)