| perturb {dembase} | R Documentation |
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.
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)
object |
Object of class |
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 |
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.
An object of the same class as object. If n > 1, the
return value has a dimension with dimtype "Iterations"; otherwise it
does not.
The log-linear model is fitted using loglm.
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