| isConsistent {dembase} | R Documentation |
Test whether the components and population counts counts of a
DemographicAccount conform to the accounting identity
that population at the end of a period equals population at the beginning
of a period plus entries minus exits, along with the constraint
that population counts and the number of people reaching each exact
age, are always non-negative. Entries include events such as
births and in-migration, and exits include events such as deaths
and out-migration. The accounting identities are applied cell by cell.
isConsistent(object) ## S4 method for signature 'Movements' isConsistent(object)
object |
The return value is an array of logical values. To test whether
every cell in an account is consistent, without identifying the
inconsistent cells, use function all, as in
all(isConsistent(myaccount))
An array of logical values.
## A consistent account
population <- Counts(array(c(10, 15, 13, 16),
dim = c(2, 2),
dimnames = list(age = c("0-29", "30+"),
time = c(1970, 2000))))
births <- Counts(array(13,
dim = c(1, 1),
dimnames = list(age = "30+",
time = "1971-2000")))
deaths <- Counts(array(c(0, 9),
dim = c(2, 1),
dimnames = list(age = c("0-29", "30+"),
time = c("1971-2000"))))
account <- Movements(population = population,
births = births,
exits = list(deaths = deaths))
isConsistent(account)
all(isConsistent(account))
## An inconsistent account
population <- Counts(array(c(10, 15, 13, 16),
dim = c(2, 2),
dimnames = list(age = c("0-29", "30+"),
time = c(1970, 2000))))
births <- Counts(array(14, # changed from 13
dim = c(1, 1),
dimnames = list(age = "30+",
time = "1971-2000")))
deaths <- Counts(array(c(0, 9),
dim = c(2, 1),
dimnames = list(age = c("0-29", "30+"),
time = c("1971-2000"))))
account <- Movements(population = population,
births = births,
exits = list(deaths = deaths))
isConsistent(account)
all(isConsistent(account))