perturb: Generate demographic array consisting of random values.

Description Usage Arguments Details Value See Also Examples

Description

If object has a dimension with dimtype "Iterations", then perturb returns n randomly-selected iterations. Otherwise, it fits a log-linear model to the data and uses this to randomly generate n iterations. The log-linear model by default contains 2-way interactions; higher or lower values can be specified via order.

Usage

1
2
3
4
perturb(object, n = 1L, order = 2L, phi = 1, subtotals = NULL)

## S4 method for signature 'DemographicArray'
perturb(object, n = 1L, order = 2L, phi = 1, subtotals = NULL)

Arguments

object

Object of class DemographicArray.

n

Number of iterations to generate.

order

Order of interations used in log-linear models.

phi

A positive number governing the amount of random noise: higher values imply more variation.

subtotals

Not implemented yet

Details

Arguments order and phi only have an effect when a log-linear model is fitted - in other words, when object does not have dimtype "Iterations".

object can contain missing values, though if a log-linear model is fitted, there must be sufficient observations for a model with order-way interations.

Value

An object of the same class as object. If n > 1, the return value has a dimension with dimtype "Iterations"; otherwise it does not.

See Also

The log-linear model is fitted using loglm.

Examples

1
2
3
4
5
6
7
8
library(demdata)
x <- Values(VADeaths2)
perturb(x)
perturb(x, phi = 2) ## greater variance
perturb(x, order = 1) ## log-linear model only includes main effects
perturb(x, n = 2)
x10 <- perturb(x, n = 10)
perturb(x10, n = 2)  ## iterations selected, rather than generated

StatisticsNZ/dembase documentation built on Dec. 25, 2021, 4:49 p.m.