View source: R/mvrnormSeries.R
mvrnormSeries | R Documentation |
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.
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)
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 |
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 |
sigma.u.dyn |
A vector of length |
rho.u.dyn |
For |
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 |
sigma.u.RY |
A vector of length |
rho.u.RY |
For |
tol |
A tolerance parameter used by |
conditional.mean |
If true, the function will also return the generated values of the random effects. |
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.
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.
Robert E. Fay
mvrnorm
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.