Skip to content

Commit

Permalink
pop limit checked only if migration is negative
Browse files Browse the repository at this point in the history
  • Loading branch information
hanase committed May 23, 2024
1 parent f10a48c commit 4d747a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Argument pasfr.ignore.phase2 added to pop.predict.subnat.

Additional steps for very young and very old child-bearing ages in kantorova.pasfr function.

Decreased minimum allowed population in an age group from 0.0005 to 0.
Minimum allowed population in an age group checked only if migration is negative.

10.0-0/1 (08/09/2023)
------
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: bayesPop
Type: Package
Title: Probabilistic Population Projection
Version: 10.0-1.9012
Date: 2024-05-22
Version: 10.0-1.9013
Date: 2024-05-23
Author: Hana Sevcikova, Adrian Raftery, Thomas Buettner
Maintainer: Hana Sevcikova <[email protected]>
Depends: R (>= 3.5.0), bayesTFR (>= 7.1-0), bayesLife (>= 5.0-0), MortCast (>= 2.6-1)
Expand Down
8 changes: 5 additions & 3 deletions src/projection_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void CCM(int *nobserved, int *abridged, int *npred, double *MIGm, double *MIGf,

double csfm[adim],csff[adim]; /* cohort separation factor males, females*/

const double minpop = 0; /* 0.0005; minimum accepted population */
const double minpop = 0.0005; /* minimum accepted population */
const double max_out_rate = -0.8; /* the maximum portion of population that can leave when using migration rates */

nrow = *migr;
Expand Down Expand Up @@ -289,9 +289,11 @@ void CCM(int *nobserved, int *abridged, int *npred, double *MIGm, double *MIGf,
/* add migration at the end of the interval, adjust negative population and compute total pop */
totp[j] = 0;
for(i=0; i < adim; ++i) {
migendm[i][jve] = fmax(migendm[i][jve], -popm[i+t] + minpop); /* adjust migration if it would yield negative population */
if(migendm[i][jve] < 0)
migendm[i][jve] = 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];
migendf[i][jve] = fmax(migendf[i][jve], -popf[i+t] + minpop);
if(migendf[i][jve] < 0)
migendf[i][jve] = 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];
}
Expand Down

0 comments on commit 4d747a5

Please sign in to comment.