-
Notifications
You must be signed in to change notification settings - Fork 3
/
spm_COVID_PV.m
45 lines (39 loc) · 1.55 KB
/
spm_COVID_PV.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
45
function spm_COVID_PV(DCM,i,T)
% FORMAT spm_COVID_PV(DCM,i,T)
% remove ( > T) data from country ( = i)
%--------------------------------------------------------------------------
% i - country index
% T - number of days to withhold
%__________________________________________________________________________
% Copyright (C) 2020 Wellcome Centre for Human Neuroimaging
% Karl Friston
% $Id: spm_COVID_PV.m 7866 2020-05-30 09:57:38Z karl $
# SPDX-License-Identifier: GPL-2.0
% use priors from parametric empirical Bayes
%--------------------------------------------------------------------------
pE = DCM{i}.M.pE;
pC = DCM{i}.M.pC;
data = DATA_COVID_JHU;
data(i).death = data(i).death(1:end - T);
data(i).cases = data(i).cases(1:end - T);
% invert (using incomplete data) and plot confidence intervals
%--------------------------------------------------------------------------
Y = [data(i).death, data(i).cases];
[F,Ep,Cp] = spm_COVID(Y,pE,pC);
fig = ['predictive validity: ' data(i).country];
spm_figure('GetWin',fig); clf
spm_COVID_ci(Ep,Cp,Y,1:3);
% retrieve and overlay withheld data
%--------------------------------------------------------------------------
data = DATA_COVID_JHU;
Y = [data(i).death, data(i).cases];
NY = size(Y,1);
t = (1:NY)/7;
CY = cumsum(Y(:,1));
i = (NY - T):NY;
t = t(i);
spm_figure('GetWin',fig);
subplot(3,2,1), hold on, plot(t,Y(i,1),'.r','MarkerSize',16)
subplot(3,2,3), hold on, plot(t,Y(i,2),'.r','MarkerSize',16)
subplot(2,2,2), hold on, plot(t,CY(i), '.r','MarkerSize',16)
return