forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsimMapLogLikelihood.m
44 lines (36 loc) · 1.17 KB
/
gpsimMapLogLikelihood.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function ll = gpsimMapLogLikelihood(model, df)
% GPSIMMAPLOGLIKELIHOOD Compute the log likelihood of a GPSIMMAP model.
% FORMAT
% DESC computes the log likelihood of the given Gaussian process
% for use in a single input motif protein network.
% ARG model : the model for which the log likelihood is computed.
% RETURN ll : the log likelihood of the data set.
%
% SEEALSO : gpsimMapCreate, gpsimMapLogLikeGradient, gpsimMapObjective
%
% COPYRIGHT : Neil D. Lawrence, 2006
%
% MODIFIED : Pei Gao, 2008
% SHEFFIELDML
numData = length(model.t);
% ll = model.f'*model.invK*model.f ...
% + log(det(eye(size(model.W))+model.K*model.W));
ll = model.f'*model.invK*model.f ...
- model.logDetCovf + model.logDetK;
if isfield(model, 'includeNoise') && model.includeNoise
noiseMat = ones(length(model.t), 1)*model.noiseVar;
yvar = model.yvar + noiseMat;
else
yvar = model.yvar;
end
for i = 1:numData
for j = 1:model.numGenes
ind = i + (j-1)*numData;
beta_ij = 1/yvar(ind);
factor = (model.ypred(model.times_index(i), j)...
- model.y(ind));
ll = ll + factor*factor*beta_ij - log(beta_ij);
end
end
ll = ll + numData*model.numGenes*log(2*pi);
ll = -.5*ll;