楼主: wxxstar21
693 0

[宏观经济学教材] 萨金特版本宏观经济学程序问题 [推广有奖]

  • 2关注
  • 3粉丝

院士

19%

还不是VIP/贵宾

-

威望
0
论坛币
83 个
通用积分
191.0733
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
84060 点
帖子
1396
精华
0
在线时间
1910 小时
注册时间
2013-8-7
最后登录
2024-5-19

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
第二版第46页程序bigshow2.m无法生成2.5.1等图片应该采用showall3.m。
% showall3
% program to compute impulse response, spectrum, covariogram
% and realization of scalar process
% den(L) y_t = num(L) e_t
% where e_t is a white noise.  

%   e.g2.5.1.,   num=1;den=[1 -.9];
    e.g2.5.2.,   num=[1 0 0 0 0];den=[1 0 0 0 -.8];
    e.g.2.5.3    num=[1 -.7];den=[1 -.98];
    e.g.2.5.4,   num=[1 0 0]; den=[1 -1.3 .7];
% these must be fed in  See below.
% The order of the denominator must be at least as great as the order of
% the numerator.
%  N is a paramter the number of ordinates in spectrum, see below
%  M is number of ordinates in spectrum
%  2*MM is number of points plotted in covariogram
%  TT is size of sample path plotted

sys4=tf(num,den,1)  % define the system


%    get impulse response function

M=30;  % length of impulse response function.  We might want to
      % make this a parameter in a function.
yi=impulse(sys4,M+length(den));
subplot(2,2,1)
stem([0:M],yi(length(den):M+length(den))),title('impulse response')

% now compute spectrum
%  set the ordinates
% must space the w's correctly to get the inversion formula

N=128; NN=N/2;   % Make N a parameter, the number of ordinates in spectrum
tt=[0:N-1];  
w=2*pi.*tt/N;


h4=freqresp(sys4,w);
hh4=squeeze(h4);   %  same as hh3=reshape(h3,1,100)

spect=hh4.*conj(hh4);
subplot(2,2,2);
semilogy(w(1:NN+1)',spect(1:NN+1)),title('spectrum')
axis([0 pi -inf inf])

% now compute covariance function

cov=ifft(spect);  % This wraps around.  Must unwrap it as follows



MM=15;  %  Set MM << NN. MM determines how many covariances are plotted

jj=[-MM:1:MM]
ccov=[cov(N-MM+1:1:N)' cov(1:MM+1)'];
ccov=real(ccov)

subplot(2,2,3)
stem(jj',ccov')
axis([-MM MM min(ccov) inf]),title('covariogram')


TT=90;  %  Size of sample path
u=randn(5*TT,1);
y=lsim(sys4,u);
subplot(2,2,4)
plot(y(4*TT+1:5*TT)), title('sample path')
axis([1 TT -inf inf])

二维码

扫码加我 拉你入群

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

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

关键词:宏观经济学 宏观经济 萨金特 经济学 covariance

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

本版微信群
加JingGuanBbs
拉您进交流群

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

GMT+8, 2024-5-22 00:17