diff --git a/DESCRIPTION b/DESCRIPTION index ebec30e..6163790 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bayesPop Type: Package Title: Probabilistic Population Projection -Version: 10.0-1.9013 +Version: 10.0-1.9014 Date: 2024-05-23 Author: Hana Sevcikova, Adrian Raftery, Thomas Buettner Maintainer: Hana Sevcikova diff --git a/src/projection_functions.c b/src/projection_functions.c index aaa0d99..8a646a8 100644 --- a/src/projection_functions.c +++ b/src/projection_functions.c @@ -290,10 +290,10 @@ void CCM(int *nobserved, int *abridged, int *npred, double *MIGm, double *MIGf, totp[j] = 0; for(i=0; i < adim; ++i) { if(migendm[i][jve] < 0) - migendm[i][jve] = fmax(migendm[i][jve], -popm[i+t] + minpop); /* adjust migration if it would yield negative population */ + migendm[i][jve] = fmin(0, fmax(migendm[i][jve], -popm[i+t] + minpop)); /* adjust migration if it would yield negative population */ popm[i+t] = popm[i + t] + migendm[i][jve]; if(migendf[i][jve] < 0) - migendf[i][jve] = fmax(migendf[i][jve], -popf[i+t] + minpop); + migendf[i][jve] = fmin(0, fmax(migendf[i][jve], -popf[i+t] + minpop)); popf[i+t] = popf[i + t] + migendf[i][jve]; totp[j] += popm[i + t] + popf[i + t]; }