Learn R Programming

demography (version 1.11)

read.demogdata: Read demographic data and construct demogdata object

Description

Read data from text files and construct a demogdata object suitable for plotting using plot.demogdata and fitting an LC or BMS model using lca or an FDA model using fdm.

Usage

read.demogdata(file, popfile, type, label, max.mx = 10, skip = 2,
                 popskip = skip, lambda)

Arguments

file
Filename containing demographic rates.
popfile
Filename containing population numbers.
type
Character string showing type of demographic series: either mortality, fertility or migration.
label
Name of area from which the data are taken.
max.mx
Maximum allowable value for demographic rate. All values greater than max.mx will be set to max.mx.
skip
Number of lines to skip at the start of file.
popskip
Number of lines to skip at the start of popfile.
lambda
Box-Cox transformation parameter to be used in modelling and plotting. If missing, default values are 0 (for mortality), 0.4 (for fertility) and 1 (for migration).

Value

  • Object of class demogdata with the following components:
  • yearVector of years
  • ageVector of ages
  • rateA list containing one or more rate matrices with one age group per row and one column per year.
  • popA list of the same form as rate but containing population numbers instead of demographic rates.
  • typeType of object: mortality, fertility or migration.
  • labellabel

Details

All data are assumed to be text files with the first column containing the year of observation and the second column containing the age level. All remaining columns are assumed to be demographic rates for sections of the population. The first row of the text file is assumed to contain the names of each column. Population data are assumed to have the same format but with population numbers in place of rates. Note that this format is what is used by the Human Mortality Database http://www.mortality.org. If popfile contains the Exposures and file contains the Mx rates from the HMD, then everything will work seamlessly.

See Also

demogdata

Examples

Run this code
norway <- read.demogdata("Mx_1x1.txt", "Exposures_1x1.txt",
    type="mortality", label="Norway")

Run the code above in your browser using DataLab