楼主: nmmbruno
1105 2

[问答] matlab 求教 (行为总体经济学) [推广有奖]

  • 0关注
  • 0粉丝

初中生

19%

还不是VIP/贵宾

-

威望
0
论坛币
4 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
619 点
帖子
5
精华
0
在线时间
17 小时
注册时间
2014-1-13
最后登录
2014-5-29

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  跪求在以下这本书的第七章(资产价格) 的绘图代码其中第三章有基本的代码 是学校作业但实在不会啊 拜托各位了!

第三章基础行为模型的代码我已经试出 但实在不懂绘图的X,Y需要怎么放 一直试不出来 恳求帮忙


  发布资源
   如以下格式:
   书名:Behavioral macroeconomics
   作者:Paul De Grauwe
   出版社:http://www.econ.kuleuven.be/ew/academic/intecon/Degrauwe/PDG-papers/Contributions%20to%20books/Behavioral%20Macro%20Book-Fin.pdf
   主要内容:行为总体经济学
   目录:Chapter 7: Stock Prices and Monetary Policy









二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB 总体经济学 matla atlab Mat 经济学 matlab 出版社 模型 学校

沙发
Xaero 发表于 2014-1-25 08:55:31 |只看作者 |坛友微信交流群
把问题相关的代码都拷贝出来吧。很多人都不会有时间去下载书来找代码的。
十年一觉扬州梦。
智不足以Academy,才尚不够Industry,情无力于Life。

使用道具

藤椅
nmmbruno 发表于 2014-1-26 17:14:49 |只看作者 |坛友微信交流群
好的

附件前几页是作者给的代码
最后面加上资产价格是我自己设的代码
我需要跑出跟chap7 一样的图来
再麻烦高手了


Behaviormodel

pstar=0

a1=0.5             %coefficient of expected output inoutput equation

a2=-0.2            %a2 is the interest elasticity ofoutput demand

b1=0.5            %b1 is coefficient of expectedinflation in inflation equation

b2=0.05            %b2 is coefficient of output in inflationequation

c1=1.5            %c1 is coefficient of inflation inTaylor equation

c2=0.5            %c2 is coefficient of output inTaylor equation

c3=0.5             %interest smoothing parameter inTaylor equation

beta=1

delta=2

gamma=1

sigma1=0.5            %standard deviation shocks output

sigma2=0.5            %standard deviation shocksinflation

sigma3=0.5            %standard deviation shocks Taylor

rho=0.5

mm=1               %switching parameter gamma in BrockHommes

pstar=0              % the central bank's inflationtarget

eprational=0          % if all agents have rational forecast ofinflation this parameter is 1

epextrapol=0          % if all agents use inflation extrapolationthis parameter is 1

A=[1 -b2;-a2*c11 -a2*c2]

A=[1 -b2;-a2*c1 1-a2*c2]

B=[b1 0;-a2 a1]

C=[1-b1 0;0 1-a1]

T=2000

TI=250

K=50                %length of period to computedivergence

rho=0.5

rhoout=0.0

rhoinf=0.0

rhotayl=0.0

rhoBH=0.0

epfs=pstar

p=zeros(T,1)

y=zeros(T,1)

plagt=zero(T,1)

plagt=zeros(T,1)

ylagt=zeros(T,1)

r=zeros(T,1)

epf=zeros(T,1)

epc=zeros(T,1)

ep=zeros(T,1)

ey=zeros(T,1)

CRp=zeros(T,1)

FRp=zeros(T,1)

alfapt=zeros(T,1)

eyfunt=zeros(T,1)

CRy=zeros(T,1)

FRy=zeros(T,1)

alfayt=zeros(T,1)

anspirits=zeros(T,1)

epsilont=zeros(T,1)

etat=zeros(T,1)

ut=zeros(T,1)

alfap=0.5

alfay=0.5

K1=K+1

for t=2:T

epsilont(t)=rhoout*epsilont(t-1) +sigma1*randn     %shocks in output equation (demand shock)

etat(t)=rhoinf*etat(t-1)+ sigma2*randn            %shocksin inflation equation (supply shock)

ut(t)=rhotayl*ut(t-1)+sigma3*randn               %shocksin Taylor rule (interest rate)

epsilon=epsilont(t)

u=ut(t)

shocks=[eta;as*u+epsilon]

epcs=p(t-1)

if eprational==1

eps=p(t-1)

end

eps=alfap*epcs+(1-alfap)*epfs

epcs

epcs=p(t-1)

for t=2:T

epcs=p(t-1)

eps=alfap*epcs+(1-alfap)*epfs

if epextrapol==1

eps=p(t-1)

end

eychar

eychar=y(t-1)

eyfun=0+randn/2

eyfunt(t)=eyfun

eys=alfay*eychar+(1-alfay)*eyfun

forecast=[eps;eys]

plag=p(t-1)

ylag=y(t-1)

rlag=r(t-1)

lag=[plag;ylag]

smooth=[0;a2*c2]

D=B*forecast+C*lag+smooth*rlag+shocks

X = A\D

p(t)= X(1,1)

y(t)= X(2,1)

r(t)= c1*p(t)+c2*y(t)+c3*r(t-1)+u

if square==1

r(t)= c1*(p(t))^2+c2*y(t)+c3*r(t-1)+u

end

plag(t)=p(t-1)

ylag(t)=y(t-1)

CRp(t)=rho*CRp(t-1) - (1-rho)*(epcs-p(t))^2

FRp(t)=rho*FRp(t-1) - (1-rho)*(epfs-p(t))^2

CRy(t)=rho*CRy(t-1) -(1-rho)*(eychar-y(t))^2

FRy(t)=rho*FRy(t-1) -(1-rho)*(eyfun-y(t))^2

alfap=(rhoBH*alfapt(t-1)+(1-rhoBH)*exp(mm*CRp(t)))/(exp(mm* CRp(t))+exp(mm*FRp(t)))

alfay=(rhoBH*alfayt(t-1)+(1-rhoBH)*exp(mm*CRy(t)))/(exp(mm* CRy(t))+exp(mm*FRy(t)))

alfapt(t)=alfap

alfayt(t)=alfay

if eychar>0

anspirits(t)=alfay

end

eychar=y(t-1)

if eychar>0

anspirits(t)=alfay



end

if eychar<0

anspirits(t)=1-arfay

end

autocory=corrcoef(y,ylagt)

autocorp=corrcoef(p,plagt)

coroutanimal=corr(y,anspirits)

coroutanimal=corrcoef(y,anspirits)

kurt=kurtosis(y)

[jb,pvalue,jbstat]=jbtest(y,0.05)























来源
http://www.econ.kuleuven.be/ew/academic/intecon/Degrauwe/PDG-papers/Contributions%20to%20books/Behavioral%20Macro%20Book-Fin.pdf

hw_chap6_2.doc

67.5 KB

code

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-5 04:27