plot.poplab {poplab} | R Documentation

## Plot the age profile of a simulated population

### Description

Plot a comparison between the simulated population and real population age profiles for a specified calendar year, separately for females and males.

The function looks in the specified folder for 2 tab-separated files containing age-specific counts from the real female and male population.

### Usage

    ## S3 method for class 'poplab':
    plot (x, option, population.fem,
    population.male, year, folder, ...)

### Arguments

`x` | an object returned by the `create.baseline.complete` or the `simped` functions.
`option` | simulated population source. 2 possible values `"base"` and `"current"` (see Details). The default is `"current"`.
`population.fem` | name (quoted) of the tab-separated file storing age-specific counts from the real female population (e.g. `"populationfem.txt"`).
`population.male` | name (quoted) of the tab-separated file storing age-specific counts from the real male population (e.g. `"populationmale.txt"`)
`year` | the year for which to plot the comparison
`folder` | folder (quoted) where the function looks for the real population files. For example, it might be your R_HOME/library/poplab/data/ directory, where R_HOME is the location where R is installed on your computer (see Examples below).
`...` | further arguments passed to or from other methods

### Details

`option` specifies which simulated population to be displayed:
`"base"` requires a virtual baseline population (an object returned by the `create.baseline.complete` function or the first list component returned by the `simped` function).
`"current"` requires the population alive during the year specified by `year`; this is the second component of the list returned by the `simped` function.

### Note

(1) If `yyyy` is the value of `year` and is smaller than the last simulated year (either the `baseyear` when plotting a baseline population or the `endyear` when plotting an evolved population), the function will first exclude from the simulated population those individuals born after `yyyy`.

(2) If `yyyy` is greater than the last simulated year, the function will plot a comparison of the real population of the year `yyyy` and the simulated population that was still alive during the last simulated year, only older with the calendar interval between the last simulated year and `yyyy`. This is not a recommended use of the function.

### See Also

`create.baseline.complete`, `simped`, `print.poplab`

### Examples

    ## Not run:
    For the following examples it is necessary to load the simpop
    object or to use the simped function and assign the result to
    a variable called 'simpop'.
    ## End(Not run)

    ## load simulate the population for the calendar period 1955-2002:

    load (file = file.path(system.file("data", package = "poplab"),
    "simpop.Rdata"))

    ## plot the simulated population versus the real population
    ## for the calendar year 1990:
    plot.poplab(x = simpop, option = "current", population.fem =
    "populationfem.txt", population.male = "populationmale.txt",
    year = 1990, folder =
    system.file("data", package = "poplab"))

    ## plot the baseline population versus the real population
    ## for the calendar year 1955:
    plot.poplab(x = simpop, option = "base", population.fem =
    "populationfem.txt", population.male = "populationmale.txt",
    year = 1955, folder =
    system.file("data", package = "poplab"))

[Package poplab version 1.0.2 Index]