Skip to content

Commit f8f5dba

Browse files
committed
fix error in filtering of SEIR and Two-Species models
1 parent 3ede5dc commit f8f5dba

25 files changed

+47
-45
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: phylopomp
22
Type: Package
33
Title: Phylodynamic Inference for POMP Models
4-
Version: 0.14.7.0
5-
Date: 2024-11-06
4+
Version: 0.14.8.0
5+
Date: 2024-11-15
66
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="[email protected]",comment=c(ORCID="0000-0001-6159-3207")),
77
person(given=c("Qianying"),family="Lin",role=c("aut"),comment=c(ORCID="0000-0001-8620-9910"))
88
)

inst/NEWS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_h_y_l_o_p_o_m_p'
22

3-
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_6:
3+
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_4:
44

55
• The filtering codes for the two-species model are now
66
working.
77

88
• A new sample/death event-type has been introduced into the
99
‘genealogy_t’ type.
1010

11-
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_4:
11+
• Corrections of filtering equations for the SEIR and
12+
Two-species models.
1213

1314
• Yet another refactoring. The SEIRS, LBDP, and SIRS models
1415
have been refactored to streamline the filtering calculations

inst/NEWS.Rd

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
\name{NEWS}
22
\title{News for package `phylopomp'}
3-
\section{Changes in \pkg{phylopomp} version 0.16}{
3+
\section{Changes in \pkg{phylopomp} version 0.14}{
44
\itemize{
55
\item The filtering codes for the two-species model are now working.
66
\item A new sample/death event-type has been introduced into the \code{genealogy_t} type.
7-
}
8-
}
9-
\section{Changes in \pkg{phylopomp} version 0.14}{
10-
\itemize{
7+
\item Corrections of filtering equations for the SEIR and Two-species models.
118
\item Yet another refactoring.
129
The SEIRS, LBDP, and SIRS models have been refactored to streamline the filtering calculations in a generalizable fashion.
1310
}

src/seirs_pomp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ void seirs_gill
288288
break;
289289
case 2: // transmission, s=(1,0)
290290
assert(S>=1);
291-
S -= 1; E += 1;
292-
ll += log(1-ellI/I)-log(E);
293291
change_color(color,nsample,random_choice(ellI),1,0);
294292
ellE += 1; ellI -= 1;
293+
S -= 1; E += 1;
294+
ll += log(1-ellI/I)-log(E);
295295
assert(!ISNAN(ll));
296296
break;
297297
case 3: // progression, s=(0,0)
@@ -302,10 +302,10 @@ void seirs_gill
302302
break;
303303
case 4: // progression, s=(0,1)
304304
assert(E>=1);
305-
E -= 1; I += 1;
306-
ll -= log(I);
307305
change_color(color,nsample,random_choice(ellE),0,1);
308306
ellE -= 1; ellI += 1;
307+
E -= 1; I += 1;
308+
ll -= log(I);
309309
assert(!ISNAN(ll));
310310
break;
311311
case 5: // recovery

src/twospecies_pomp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,17 @@ static double event_rates
114114
*logpi = 0; logpi++;
115115
assert(R_FINITE(event_rate));
116116
// 2: Trans_21, s = (0,0),(1,0)
117+
// s = (0,0): pi = (I1-ell1)/I1, m = 1,
118+
// s = (1,0): pi = 1/(2*I1), m = ell1
119+
// total pi = (I1-0.5*ell1)/I1
117120
assert(S2>=0 && I1>=ell1 && ell1>=0);
118121
alpha = (N1 > 0) ? Beta21*S2*I1/N1 : 0;
119122
pi = (I1 > 0) ? (I1-0.5*ell1)/I1 : 0;
120123
event_rate += (*rate = alpha*pi); rate++;
121124
*logpi = log(pi); logpi++;
122125
assert(R_FINITE(event_rate));
123126
// 3: Trans_21, s = (0,1)
127+
// s = (0,1): pi = 1/(2*I1), m = ell1
124128
pi = 1-pi;
125129
event_rate += (*rate = alpha*pi); rate++;
126130
*logpi = log(pi)-log(ell1); logpi++;
@@ -531,9 +535,9 @@ void twospecies_gill
531535
case 3: // 3: Trans_21, s = (0,1)
532536
assert(S2>=1 && I1>=0);
533537
S2 -= 1; I2 += 1;
534-
ll += log(1-ell1/I1)-log(I2);
535538
change_color(color,nsample,random_choice(ell1),host1,host2);
536539
ell1 -= 1; ell2 += 1;
540+
ll += log(1-ell1/I1)-log(I2);
537541
assert(check_color(color,nsample,ell1,ell2));
538542
assert(!ISNAN(ll));
539543
break;
@@ -546,9 +550,9 @@ void twospecies_gill
546550
case 5: // 5: Trans_12, s = (1,0)
547551
assert(S1>=1 && I2>=0);
548552
S1 -= 1; I1 += 1;
549-
ll += log(1-ell2/I2)-log(I1);
550553
change_color(color,nsample,random_choice(ell2),host2,host1);
551554
ell2 -= 1; ell1 += 1;
555+
ll += log(1-ell2/I2)-log(I1);
552556
assert(check_color(color,nsample,ell1,ell2));
553557
assert(!ISNAN(ll));
554558
break;

tests/curtail.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
2+
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

tests/diagram.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
2+
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

tests/gendat.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
2+
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

tests/lbdp1.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
2+
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

tests/lbdp2.Rout.save

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
2+
R version 4.4.2 (2024-10-31) -- "Pile of Leaves"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

0 commit comments

Comments
 (0)