Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mean.demogdata

Mean and median functions for data of class demogdata


Description

Computes mean or median of demographic rates for each age level.

Usage

## S3 method for class 'demogdata'
mean(x, series = names(x$rate)[1],
  transform = TRUE, na.rm = TRUE, ...)

## S3 method for class 'demogdata'
median(x, na.rm = FALSE, series = names(x$rate)[1],
  transform = TRUE, method = c("hossjercroux", "coordinate"), ...)

Arguments

x

Demogdata object such as created using read.demogdata or smooth.demogdata.

series

Name of demogdata series to plot..

transform

Should transform of data be taken first?

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

...

Other arguments.

method

Method for computing the median. Either "coordinate" for a coordinate-wise median, or "hossjercroux" for the L1-median using the Hossjer-Croux algorithm.

Value

A list containing x=ages and y=mean or median rates.

Author(s)

Rob J Hyndman

References

Hossjer, O., and Croux, C. (1995) Generalized univariate signed rank statistics for testing and estimating a multivariate location parameter. Nonparametric Statistics, 4, 293-308.

Examples

plot(fr.mort)
lines(mean(fr.mort),lwd=2)
lines(median(fr.mort),lwd=2,col=2)

demography

Forecasting Mortality, Fertility, Migration and Population Data

v1.22
GPL (>= 2)
Authors
Rob J Hyndman with contributions from Heather Booth, Leonie Tickle and John Maindonald.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.