spm_dcm_optimise.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. function [varargout] = spm_dcm_optimise(qE,qC,pE,pC,priorfun,varargin)
  2. % Optimises the priors of a model (under Laplace approximation)
  3. % FORMAT [rE,rC] = spm_dcm_optimise(qE,qC,pE,pC,priorfun,varargin)
  4. %
  5. % qE,qC - posterior expectation and covariance of model
  6. % pE,pC - prior expectation and covariance of model
  7. % priorfun - inline function that returns priors
  8. % {rE rC} = priorfun(varargin{:})
  9. %
  10. % rE,rC - optimal priors defining a reduced model
  11. %
  12. %--------------------------------------------------------------------------
  13. % This routine optimizes the prior covariance on the free parameters of any
  14. % model (DCM) under the Laplace approximation. In other words, it assumes
  15. % that the prior means are fixed and will maximise model evidence with
  16. % respect to the hyperparameters of a function that returns the prior
  17. % covariance. This optimization uses the reduced free-energy, based upon
  18. % the posterior and prior densities of the full model supplied. If the
  19. % prior covariance function is not specified, this routine will assume a
  20. % simple diagonal form with a single hyperparameter. In principle, this
  21. % routine can be used in a flexible and powerful way to emulate
  22. % hierarchical modeling by using suitable prior covariance functions with
  23. % unknown hyperparameters. The outputs are the prior moments (mean and
  24. % covariance) of the optimum model.
  25. %__________________________________________________________________________
  26. % Copyright (C) 2008-2011 Wellcome Trust Centre for Neuroimaging
  27. % Karl Friston
  28. % $Id: spm_dcm_optimise.m 4261 2011-03-24 16:39:42Z karl $
  29. % Compute reduced log-evidence
  30. %==========================================================================
  31. % default prior function
  32. %--------------------------------------------------------------------------
  33. if nargin == 4
  34. priorfun = inline('{v2, diag(exp(v1))}','v1','v2');
  35. varargin{1} = log(diag(pC));
  36. varargin{2} = pE;
  37. end
  38. varargout = spm_argmax('spm_log_evidence',qE,qC,pE,pC,priorfun,varargin{:},6);
  39. varargin{1} = varargout;
  40. varargout = priorfun(varargin{:});