interpolatePop | R Documentation |
The interpolation is done by age (not cohort) using a linear or exponential function. This comes from the PAS spreadsheet called ADJINT.
interpolatePop(
Pop1,
Pop2,
Date1,
Date2,
DesiredDate,
method = "linear",
roundoutput = FALSE
)
Pop1 |
numeric. A vector of demographic counts by age at time 1 (earlier date). |
Pop2 |
numeric. A vector of demographic counts by age at time 2 (later date). |
Date1 |
date. The date corresponding to the population age distribution at time 1. See details for ways to express it. |
Date2 |
date. The date corresponding to the population age distribution at time 2. See details for ways to express it. |
DesiredDate |
date. The desired date of the output population age distribution. See details for ways to express it. |
method |
string. The method to use for the interpolation, either "linear" or "exponential". Default "linear". |
roundoutput |
logical. Whether or not to return integers. Default |
The age group structure of the output is the same as that of the input. Ideally, DesiredDate
should be between the Date1 and Date2.
Dates can be given in three ways 1) a Date
class object, 2) an unambiguous character string in the format "YYYY-MM-DD"
,
or 3) as a decimal date consisting in the year plus the fraction of the year passed as of the given date.
A vector of the interpolated population for the requested date.
Sean Fennel
PASDemoTools
# YYYY-MM-DD dates as character
EarlyDate <- "1980-04-07"
LaterDate <- "1990-10-06"
DesiredDate <- "1985-07-01"
interpolatePop(popA_earlier, popA_later, EarlyDate, LaterDate, DesiredDate)
interpolatePop(popA_earlier, popA_later, EarlyDate, LaterDate, DesiredDate, method = "exponential")
## Not run:
plot(popA_earlier, t ='l', col='red',
ylim = c(400,1220000),
ylab = 'The counts', xlab = 'Age groups')
lines(interpolatePop(popA_earlier, popA_later, EarlyDate, LaterDate, DesiredDate),
t = 'l', col='black')
lines(popA_later,
t = 'l', col='blue')
legend(12,1000000,
legend = c('Pop in 1980-04-07',
'Pop in 1985-07-01',
'Pop in 1990-10-06'),
col=c('red','black','blue'),
lty = 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.