I.B
I.B

Reputation: 1

Impulse Response Function with bootsrtapped Confidence intervals matlab

I have an impulse response of consumption data using an AR(8) model. Now I want to create a 95% CI around the IRF using bootstrapping. I am not sure what parameters I should bootstrap.

This code is for generating bootstraps in general but I can't see how to use this to plot the CI around the IRF in the graph.

mu=20;
sigma=5;
N=250;

rng(1);
x=mu+sigma*randn(N,1)
muhat=mean(x);
e=x-muhat;
for i=1:B
 draw=randi(N,N,1);
 xn=muhat+e(draw);
 mun(i)=mean(xn);
end 

Is anyone familiar with this methodology and how I can proceed?

Thanks.


enter image description here

Code

clear;

X=xlsread('data.xls');
% Demean the data 
 mean_u=mean(X);
 X=X-mean_u*ones(length(X),1);
%Construct lag matrix 
 LM=lagmatrix(X,1:L);
 X=X(L+1:end);
 LM=LM(L+1:end,:);
 beta=LM\X;
%Begin calculating irf 
 F=companion(beta)
 e=X-LM*beta;
 sigma=std(e);
 x=zeros(L,T);
 x(1,1)=sigma;
for t=2:T
 x(:,t)=F*x(:,t-1);
end 

Upvotes: 0

Views: 823

Answers (1)

Tommaso Belluzzo
Tommaso Belluzzo

Reputation: 23675

You could use the ready-made solution provided by Matlab, the bootci function. This is an example directly taken from the official documentation:

y = normrnd(1,1,30,1);
LSL = -3; USL = 3;
capable = @(x)(USL-LSL)./(6* std(x));
ci = bootci(2000,capable,y);

All you have to do is to convert your current code into a function do that you can pass its handle to bootci.

Upvotes: 0

Related Questions