Home > wafo > markov > loglcmat.m

loglcmat

PURPOSE ^

log-Likelihood of cycle matrix.

SYNOPSIS ^

logL = logLcmat(Fobs,F,def)

DESCRIPTION ^

  LOGLCMAT  log-Likelihood of cycle matrix.
 
  computes the log-Likelihood of an observed
    cycle matrix Fobs which has the expected cycle matrix F.
 
  The log-Likelihood is
    logL = C + D,
    C = log(N!)-sum(log(N_ij!)),  D = sum(N_ij*log(g_ij))
 
  logL = logLcmat(Fobs,F,def)
 
  Fobs  = Observation of cycle matrix
  F     = Expected cycle matrix
  def   = 0: Don't compute constant part, logL=D, (default)
          1: Compute constant part, logL=C+D

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function logL = logLcmat(Fobs,F,def)
002 % LOGLCMAT  log-Likelihood of cycle matrix.
003 %
004 % computes the log-Likelihood of an observed
005 %   cycle matrix Fobs which has the expected cycle matrix F.
006 %
007 % The log-Likelihood is
008 %   logL = C + D,
009 %   C = log(N!)-sum(log(N_ij!)),  D = sum(N_ij*log(g_ij))
010 %
011 % logL = logLcmat(Fobs,F,def)
012 %
013 % Fobs  = Observation of cycle matrix
014 % F     = Expected cycle matrix
015 % def   = 0: Don't compute constant part, logL=D, (default)
016 %         1: Compute constant part, logL=C+D
017 
018 if nargin<3, def=0; end
019 
020 F = flipud(F)';       % Convert to PJ-def
021 Fobs = flipud(Fobs)'; % Convert to PJ-def
022 
023 n = length(F);
024 N = sum(sum(Fobs));
025 
026 F = F / sum(sum(F));
027 
028 FF = F(:);
029 FFobs = Fobs(:);
030 FI = find(FF>0 & FFobs>0);
031 FIobs = find(FFobs>0);
032 
033 % Copmute constant part of log-Likelihood (part C)
034 
035 if def == 1
036   logL = sum(log(1:N));
037   for k = 1:length(FIobs)
038     logL = logL - sum(log( 1:FFobs(FIobs(k)) ));
039   end
040 else
041   logL = 0;
042 end
043 
044 % Copmute log-Likelihood (part D)
045 
046 logL = logL + sum(FFobs(FI).*log(FF(FI)));
047 
048

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003