Home > spm_vbglmar_slice > spm_vb_taylor_R.m

spm_vb_taylor_R

PURPOSE ^

Get Taylor sereis approximation to posterior correlation matrices - see paper VB3

SYNOPSIS ^

function [slice] = spm_vb_taylor_R (Y,slice)

DESCRIPTION ^

 Get Taylor sereis approximation to posterior correlation matrices - see paper VB3
 FORMAT [slice] = spm_vb_taylor_R (Y,slice)

 Y     data
 slice VB-GLMAR data structure

 %W% Will Penny %E%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [slice] = spm_vb_taylor_R (Y,slice)
0002 % Get Taylor sereis approximation to posterior correlation matrices - see paper VB3
0003 % FORMAT [slice] = spm_vb_taylor_R (Y,slice)
0004 %
0005 % Y     data
0006 % slice VB-GLMAR data structure
0007 %
0008 % %W% Will Penny %E%
0009 
0010 % Get mean hyperparameter values
0011 h0=[];
0012 if slice.p > 0
0013     a=mean(slice.ap_mean');
0014     a_covs=cat(3,slice.a_cov{:});
0015     a_cov=mean(a_covs,3);
0016     slice.mean.a=a;
0017     slice.mean.a_cov=a_cov;
0018     h0=a';
0019 end
0020 
0021 slice.mean.b=mean(slice.b');
0022 
0023 lambda=mean(slice.mean_lambda);
0024 slice.mean.lambda=lambda;
0025 h0=[h0;lambda];
0026 
0027 R=spm_vb_get_R(slice,h0);
0028 slice.mean.R=R;
0029 
0030 delta=0.0001;
0031 % Get first order Taylor terms about slice
0032 % mean values of a and lambda
0033 for i=1:length(h0),
0034     h=h0;
0035     h(i)=h(i)-delta;
0036     
0037     [R1]=spm_vb_get_R(slice,h);
0038     
0039     h=h0;
0040     h(i)=h(i)+delta;
0041     % Loop over hyperparameters
0042     [R2]=spm_vb_get_R(slice,h);
0043     
0044     dR(:,:,i)=(R2-R1)/(2*delta);
0045 end
0046 slice.mean.h0=h0;
0047 slice.mean.dR=dR;

Generated on Mon 23-Aug-2004 14:59:38 by m2html © 2003