楼主: taoflower
3417 16

matlab初学者请教一问题(版主不好意思,发重复贴了。我还是认为有偿报答最好。) [推广有奖]

11
taoflower 发表于 2010-2-20 23:16:48
8# taoflower

m文件和txt数据已上传。 多谢大家。

LiuWhitedZhang_JPE.zip
下载链接: https://bbs.pinggu.org/a-554011.html

139.48 KB

本附件包括:

  • readme.txt
  • em.txt
  • bm.txt
  • IgTWX.txt
  • IgTWXret.txt
  • taxrate.txt
  • BMret.txt
  • emret.txt
  • test.m
  • gfun.m
  • main.m
  • objfun.m
  • Smatrix.m
  • std.m
  • step_size.m

12
taoflower 发表于 2010-2-21 12:44:44
11# taoflower

多谢! 已评为最佳答案。 看来还要努力学习啊  

谢谢。拜个晚年

13
taoflower 发表于 2010-2-21 23:26:19
2# esir

大哥,我研究了一下、 main的路径改了。现在运行流畅,多亏了你啊。 但是其他m文件还是不行,我打开其它的看了看没有路径的问题啊? 错误显示变量或函数未定义。  我想这些m文件是没错的,是否还是我设置的问题?   谢谢你

14
esir 发表于 2010-2-22 09:59:01
若有产生9个文件,就表示运行成功.
figures: BM.eps, em.eps, IgTWX.eps
Table 2: esti_BM, esti_em, esti_IgTWX
         (parameter estimation, a, stderr of a, kappa, stderr of kappa,
          chi-square, degree of freedom, p value, aape)

Table 3: euler_BM, euler_em, euler_IgTWX
         (Euler equation mean error , including H-L and assocaited t-stat)

你的意思,可能是要单独运行其他的Matlab files
譬如: objfun.m
    function [obj, RI, e] = objfun(x,W, input)
    %This function estimates the objective function.
    %obj is the value of the objective function
    %RI is levered investment return
    %e is Euler equation errors.
   这时你只要给出 x,W, input,三个arguments即可.

15
taoflower 发表于 2010-2-22 12:33:52
14# esir

如何给出呢? 定义么? 错误结果显示 x is undefine

16
esir 发表于 2010-2-22 19:11:25
em_demo.m
em_demo.rar (1.3 KB) 本附件包括:
  • em_demo.m



%运行em_demo,给出x,W, input 三个arguments
%呼叫function objfun算出obj, RI, e
[obj, RI, e]=objfun(x,W, input);
%呼叫function std算出S, varpara, vargT, chisq, P
[S, varpara, vargT, chisq, P] = std(x, W, input, e, dof, ynum, pnum, maxlags, stage);
%再经一连串运算,给出跟esti_em.xls 一样的outputpara
%standard error and associated tstat of the estimated parameters;
stderr=diag(varpara).^0.5;
t=[k,a]'./(diag(varpara).^0.5);

%Euler Equation error and the associated tstat;
gT=mean(e);
teuler=gT'./((diag(vargT)).^0.5);

abse=(abs(gT)); %mean absolute error
aape=mean(abse)*100; %represents return in percentage;

%Using delta method to find standard error for the function HML
%f(b)=e9-e0. f'(b)=(-1,1),
%var (e0, e9) is a part of vargT.

ffb=[-1;1];
varlh=[vargT(1,1) vargT(1,pnum);vargT(pnum,1) vargT(10,10)];
varhminl=ffb'*varlh*ffb;
hminl=mean(e(:,10)-e(:,1));
thminl=hminl/(varhminl^0.5);

%Table 2 results
disp('Table 2 resutls');
outputpara=[a; stderr(2,:); k; stderr(1,:); chisq; dof; P; aape]

17
算盘 发表于 2011-4-3 15:53:29
其实,这个挺简单的。 只要改一下路径即可

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 18:32