全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
1278 2
2014-01-22
  跪求在以下这本书的第七章(资产价格) 的绘图代码其中第三章有基本的代码 是学校作业但实在不会啊 拜托各位了!

第三章基础行为模型的代码我已经试出 但实在不懂绘图的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









二维码

扫码加我 拉你入群

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

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

全部回复
2014-1-25 08:55:31
把问题相关的代码都拷贝出来吧。很多人都不会有时间去下载书来找代码的。
二维码

扫码加我 拉你入群

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

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

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

二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群