mvrnormSeries: Generate data under the Dynamic or Rao-Yu Time Series Models

View source: R/mvrnormSeries.R

mvrnormSeriesR Documentation

Generate data under the Dynamic or Rao-Yu Time Series Models

Description

Function to generate data under a Rao-Yu time series model, a dynamic model, or a mixture of both. The function can produce either univariate or multivariate observations. All components of the returned random variable have unconditional mean zero. The function calls mvrnorm in MASS.

Usage

mvrnormSeries(NV=1,  D,  TI,  sigma.e, 
   rho.dyn,  sigma.v.dyn,  sigma.u.dyn, rho.u.dyn, 
   rho.RY,   sigma.v.RY,   sigma.u.RY,   rho.u.RY,  tol=1e-6,
   conditional.mean=FALSE)

Arguments

NV

The number of variables.

D

The number of domains.

TI

The number of time instances (constant for all domains).

sigma.e

The covariance matrix for the variation due to sampling, specified either as a single square matrix with NV*TI rows and columns, or as a list of D matrices, each with NV*TI rows and columns. The rows should vary over TI more quickly than over NV. Sampling covariances between domains are assumed to be zero.

rho.dyn

The temporal correlation parameter in the dynamic model. This parameter is not a true correlation, however, and it may exceed 1.

sigma.v.dyn

A vector of length NV with the v (nu) component of the variance under the dynamic model. This component measures the variance of the random effect at the beginning of the series.

sigma.u.dyn

A vector of length NV with the u component of the variance under the dynamic model.

rho.u.dyn

For NV>1, the cross-sectional correlation(s) under the model. The vector should specify (NV*(NV-1))/2 correlations, in lower triangular form. For example, for NV=3, the correlations should be specified in the order (2,1), (3,1), (3,2).

rho.RY

The temporal correlation parameter in the Rao-Yu model. This is a true correlation, unlike the parameter in the dynamic model.

sigma.v.RY

A vector of length NV with the v (nu) component of the variance under the Rao-Yu model. This component reflects a constant random effect for each domain unchanging over time.

sigma.u.RY

A vector of length NV with the u component of the variance under the Rao-Yu model.

rho.u.RY

For NV>1, the cross-sectional correlation under the model. The vector should specify (NV*(NV-1))/2 correlations, in lower triangular form. For example, for NV=3, the correlations should be specified in the order (2,1), (3,1), (3,2).

tol

A tolerance parameter used by mvrnorm in MASS to determine if the covariance matrix is non-singular.

conditional.mean

If true, the function will also return the generated values of the random effects.

Details

The function assembles the covariance matrix from the covariance matrix under the dynamic model (if specified), the Rao-Yu model (if specified) and a required sampling covariance matrix.

Value

If conditional.mean=FALSE, then for NV=1, a multivariate normal random vector with mean zero and length D*TI. For NV>1, a matrix with D*TI rows and NV columns.

If conditional.mean=TRUE, a list with the first element as above and a second element that is the sum of the random effects without the sampling error. Simulation studies can evaluate the small area estimates using the first element of the list as input against the second element of the list, which is the target of the small area estimation.

Author(s)

Robert E. Fay

See Also

mvrnorm

Examples

set.seed(7)
mvrnormSeries(D=2, TI=5, sigma.e=diag(5), rho.dyn=.8,
    sigma.v.dyn=2, sigma.u.dyn=.72, conditional.mean=TRUE)
mvrnormSeries(NV=2, D=2, TI=5, sigma.e=diag(10), rho.dyn=.8,
    sigma.v.dyn=2, sigma.u.dyn=.72, rho.u.dyn=.8)

sae2 documentation built on Aug. 23, 2023, 5:07 p.m.