Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TZcode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Contributions
TZcode
Commits
e264d1da
Commit
e264d1da
authored
13 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
remove files of the form *.bak
parent
d19f2aeb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MatlabFiles/Gibbsvar.bak
+0
-74
0 additions, 74 deletions
MatlabFiles/Gibbsvar.bak
with
0 additions
and
74 deletions
MatlabFiles/Gibbsvar.bak
deleted
100755 → 0
+
0
−
74
View file @
d19f2aeb
function A0gbs = gibbsvar(A0gbs,cT,vR,nvar,fss,kdf)
% A0gbs = gibbsvar(A0gbs,cT,vR,nvar,fss,kdf)
% One-step Gibbs sampler for structural VARs -- simultaneous equations approach
% Ref.: D.F. Waggoner and T.A. Zha: "Does Normalization Matter for Inference?"
% See Note Forecast (2) pp. 44-51
%
% A0gbs: the last draw of A0 matrix
% cT{i}: nvar-by-nvar where T'*T=Sbd{i} which is kind of covariance martrix
% divided by fss already
% vR{i}: nvar-by-q{i} -- orthonormral basis for T*R, which is obtained through
% single value decomposition of Q*inv(T). See gibbsglb.m
% nvar: rank of A0 or # of variables
% fss: effective sample size == nSample (T)-lags+# of dummy observations
% kdf: polynomial power in the Gamma or 1d Wishart distribution
%------------------
% A0bgs: new draw of A0 matrix in this Gibbs step
%
% Written by Tao Zha; Copyright (c) 1999 by Waggoner and Zha
%---------------- Local loop for Gibbs given last A0gbs ----------
%* uR{i}: nvar-by-q{i} -- orthonormal with first q(i)-1 vectors lies in the
% span(T*a(j)|j~=i)
%*** Constructing u(1),...,u(q{i}) at each Gibbs step
%
uR = cell(nvar,1);
sw0 = zeros(nvar,1);
for k=1:nvar % given last A0gbs and general new A0bgs
X = cT{k}*A0gbs; % given the latest updated A0gbs
X(:,k) = 0; % want to find non-zero sw s.t., X'*sw=0
[jL,Ux,Px] = lu(X');
jIx0 = min(find(abs(diag(Ux))<eps)); % if isempty(jIx0), then something is wrong here
%
sw0(jIx0+1:end) = 0;
sw0(jIx0) = 1;
jA = Ux(1:jIx0-1,1:jIx0-1);
jb = Ux(1:jIx0-1,jIx0);
jy = -jA\jb;
sw0(1:jIx0-1) = jy;
sw = sw0/sqrt(sum(sw0.^2));
%
lenk = length(vR{k}(1,:));
gkb = zeros(lenk,1); % greek beta's
uR{k} = zeros(nvar,lenk);
sx = zeros(nvar,lenk);
sx(:,1) = vR{k}(:,1);
for ki = 1:lenk-1
wxv = [sw'*sx(:,ki);sw'*vR{k}(:,ki+1)]; % w'*x and w'*v(+1)
dwxv = sqrt(sum(wxv.^2));
if (dwxv<eps)
uR{k}(:,ki)=sx(:,ki); sx(:,ki+1)=vR{k}(:,ki+1);
else
wxv = wxv/dwxv;
uR{k}(:,ki) = wxv(1)*vR{k}(:,ki+1) - wxv(2)*sx(:,ki);
sx(:,ki+1) = wxv(2)*vR{k}(:,ki+1) + wxv(1)*sx(:,ki);
end
end
uR{k}(:,lenk) = sx(:,lenk); % uR now constructed
%
%--------- Gibbs loop ----------
%*** draw independently beta's that combine uR to form a's (columns of A0)
jcon = sqrt(1/fss);
gkb(1:lenk-1) = jcon*randn(lenk-1,1);
%* gamma or 1-d Wishart draw
jnk = jcon*randn(kdf+1,1);
if rand(1)<0.5
gkb(lenk) = sqrt(jnk'*jnk);
else
gkb(lenk) = -sqrt(jnk'*jnk);
end
%
%*** form new a(i) - ith column of A0
A0gbs(:,k) = (cT{k}\uR{k})*gkb;
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment