decomposition {demest} | R Documentation

## Decompose a demographic array

### Description

Decompose a `DemographicArray` into terms made up of component dimensions, plus an error. `decomposition` is typically used to obtain initial estimates of main effects and interactions, as part of model building.

### Usage

    decomposition(object, max = NULL)

    ## S4 method for signature 'DemographicArray'
    decomposition(object, max = NULL)

### Arguments

`object` | An object of class `DemographicArray`.
`max` | An integer. Optional.

### Details

When building a Poisson model, the decomposition is usually carried out on log-rates, and when building a binomial model, it is usually carried out on logit-proportions, though in both cases other transformations (or no transformation) may be appropriate if there are lots of zeros (and also lots of ones in the case of binomial models).

The final element in the return value is an 'error' array. This equals the observed value for `object` minus the sum of the terms in the decomposition.

The `max` argument controls the maximum order of the interactions included in decomposition. For instance, if `max` is `2`, then only main effects and second-order interactions are included in the decomposition. By default, all interactions are included.

Internally, `decomposition` calls function `pairToState` on `object`, to cope with origin-destination or parent-child dimensions.

### Value

A named list, the elements of which have class `Values`.

### References

Chapter 12 of Bryant and Zhang, Bayesian Demographic Estimation and Forecasting.

### Examples

    deaths <- Counts(demdata::VADeaths2)
    popn <- Counts(demdata::VAPopn)
    rates <- deaths/popn
    log.rates <- log(rates)
    ans <- decomposition(log.rates)
    names(ans)
    ans[1:3]
    ans[["age:residence"]]
    mean(log.rates)
    round(sapply(ans, sum), 5)
    all.equal(Reduce("+", ans), log.rates)
    ## main effects only
    decomposition(log.rates, max = 1)

[Package demest version 0.0.0.3.1 Index]