vital
Tidy Analysis Tools for Mortality, Fertility, Migration and Population Data
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.3%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Tidy Analysis Tools for Mortality, Fertility, Migration and Population Data
Basic Info
- Host: GitHub
- Owner: robjhyndman
- Language: R
- Default Branch: main
- Homepage: https://pkg.robjhyndman.com/vital
- Size: 139 MB
Statistics
- Stars: 29
- Watchers: 2
- Forks: 2
- Open Issues: 8
- Releases: 2
Created almost 7 years ago
· Last pushed 10 months ago
Metadata Files
Readme
Changelog
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
# Okabe-Ito colours for discrete scales
options(
ggplot2.discrete.colour = c("#D55E00", "#0072B2", "#009E73", "#CC79A7", "#E69F00", "#56B4E9", "#F0E442"),
ggplot2.discrete.fill = c("#D55E00", "#0072B2", "#009E73", "#CC79A7", "#E69F00", "#56B4E9", "#F0E442")
)
# Fira Sans font for graphics
ggplot2::theme_set(
ggplot2::theme_get() +
ggplot2::theme(text = ggplot2::element_text(family = "Fira Sans"))
)
```
# vital
[](https://github.com/robjhyndman/vital/actions/workflows/R-CMD-check.yaml)
The goal of vital is to allow analysis of demographic data using tidy tools.
## Installation
You can install the **stable** version from
[CRAN](https://cran.r-project.org/package=vital):
```r
pak::pak("vital")
```
You can install the **development** version from
[Github](https://github.com/robjhyndman/vital):
``` r
pak::pak("robjhyndman/vital")
```
## Examples
First load the necessary packages.
```{r packages, message=FALSE}
library(vital)
library(tsibble)
library(dplyr)
library(ggplot2)
```
### vital objects
The basic data object is a `vital`, which is time-indexed tibble that contains vital statistics such as births, deaths, population counts, and mortality and fertility rates.
Here is an example of a `vital` object containing mortality data for Norway.
```{r aus}
norway_mortality <- norway_mortality |>
collapse_ages(max_age = 100)
```
We can use functions to see which variables are index, key or vital:
```{r vars}
index_var(norway_mortality)
key_vars(norway_mortality)
vital_vars(norway_mortality)
```
### Plots
```{r autoplot, warning = FALSE}
norway_mortality |>
filter(Sex != "Total", Year < 1980, Age < 90) |>
autoplot(Mortality) + scale_y_log10()
```
### Life tables and life expectancy
```{r lifetable}
# Life table for Norwegian males in 2000
norway_mortality |>
filter(Sex == "Male", Year == 2000) |>
life_table()
```
```{r e0}
# Life expectancy
norway_mortality |>
filter(Sex != "Total") |>
life_expectancy() |>
ggplot(aes(x = Year, y = ex, color = Sex)) +
geom_line()
```
### Smoothing
Several smoothing functions are provided: `smooth_spline()`, `smooth_mortality()`, `smooth_fertility()`, and `smooth_loess()`, each smoothing across the age variable for each year.
```{r smoothing}
# Smoothed data
norway_mortality |>
filter(Sex != "Total", Year == 1967) |>
smooth_mortality(Mortality) |>
autoplot(Mortality) +
geom_line(aes(y = .smooth), col = "#0072B2") +
ylab("Mortality rate") +
scale_y_log10()
```
### Mortality models
Several mortality models are available including variations on Lee-Carter models (Lee & Carter, JASA, 1992), and functional data models (Hyndman & Ullah, CSDA, 2007).
```{r lc}
fit <- norway_mortality |>
filter(Sex != "Total") |>
model(
lee_carter = LC(log(Mortality)),
fdm = FDM(log(Mortality))
)
fit
```
Models are fitted for all combinations of key variables excluding age.
```{r lc2}
fit |>
select(lee_carter) |>
filter(Sex == "Female") |>
report()
```
```{r lc3}
fit |>
select(lee_carter) |>
autoplot()
```
```{r}
fit |>
select(lee_carter) |>
age_components()
fit |>
select(lee_carter) |>
time_components()
```
```{r lc5}
fit |> forecast(h = 20)
```
The forecasts are returned as a distribution column (here transformed normal because of the log transformation used in the model). The `.mean` column gives the point forecasts equal to the mean of the distribution column.
Owner
- Name: Rob J Hyndman
- Login: robjhyndman
- Kind: user
- Location: Wurundjeri country, Australia
- Company: Monash University
- Website: https://robjhyndman.com
- Repositories: 139
- Profile: https://github.com/robjhyndman
I analyse data, develop new statistical methods, and write open source software.
GitHub Events
Total
- Issues event: 25
- Watch event: 3
- Delete event: 5
- Issue comment event: 23
- Push event: 107
- Pull request review event: 7
- Pull request review comment event: 7
- Pull request event: 15
- Fork event: 1
- Create event: 4
Last Year
- Issues event: 25
- Watch event: 3
- Delete event: 5
- Issue comment event: 23
- Push event: 107
- Pull request review event: 7
- Pull request review comment event: 7
- Pull request event: 15
- Fork event: 1
- Create event: 4
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 30
- Total pull requests: 16
- Average time to close issues: 3 months
- Average time to close pull requests: 3 days
- Total issue authors: 2
- Total pull request authors: 4
- Average comments per issue: 0.63
- Average comments per pull request: 0.44
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 6
Past Year
- Issues: 14
- Pull requests: 10
- Average time to close issues: 21 days
- Average time to close pull requests: 4 days
- Issue authors: 2
- Pull request authors: 3
- Average comments per issue: 0.57
- Average comments per pull request: 0.7
- Merged pull requests: 8
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- robjhyndman (26)
- MilesMcBain (4)
- zxzx121hinata (1)
Pull Request Authors
- MilesMcBain (9)
- zxzx121hinata (8)
- imgbot[bot] (7)
- robjhyndman (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 166 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
cran.r-project.org: vital
Tidy Analysis Tools for Mortality, Fertility, Migration and Population Data
- Homepage: https://pkg.robjhyndman.com/vital/
- Documentation: http://cran.r-project.org/web/packages/vital/vital.pdf
- License: GPL-3
-
Latest release: 2.0.0
published 10 months ago
Rankings
Dependent packages count: 28.8%
Dependent repos count: 35.4%
Average: 49.9%
Downloads: 85.6%
Maintainers (1)
Last synced:
10 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 3.6.0 depends
- cli * imports
- crayon * imports
- dplyr * imports
- fable * imports
- fabletools >= 0.3.2.9000 imports
- generics >= 0.1.2 imports
- ggplot2 * imports
- grid * imports
- gtable * imports
- magrittr * imports
- purrr * imports
- rlang * imports
- rstudioapi * imports
- tibble * imports
- tidyr * imports
- tidyselect * imports
- tsibble * imports
- demography * suggests
- mortality * suggests
- testthat >= 3.0.0 suggests