generate_Gaussian {latentgraph}R Documentation

Generate a Gaussian distributed data set

Description

This function will generate a Gaussian distributed data set with latent variables and correlated replicates.

Usage

generate_Gaussian(n, R, p, l, s, sparsityA, sparsityobserved, sparsitylatent, lwb, 
upb, seed)

Arguments

n

the number of observations.

R

the number of replicates.

p

the number of observed variables.

l

the number of latent variables.

s

latent effects are generated as ss piecewise constant across replicates. The number ss should be a factor of RR.

sparsityA

proportion of the number of zeros in the transition matrix AA. Must be a number from 0 to 1.

sparsityobserved

proportion of the number of zeros in the inverse covariance of the observed variables. Must be a number from 0 to 1.

sparsitylatent

proportion of the number of zeros in the inverse covariances among latent variables and between observed variables and latent variables. Must be a number from 0 to 1.

lwb

lower bound for the elements in the inverse covariance matrix.

upb

upper bound for the elements in the inverse covariance matrix.

seed

the seed for the random number generator.

Details

This function aims to generate a Gaussian distributed data set with latent variables and correlated replicates. For each observation, the latent variables are piecewise constant across replicates, and conditioned on the latent variables, the replicates follow a one-lag vector autoregressive model, where the transition matrix AA is sparse with non-zero elements set equal to 0.3. The matrix Σ\Sigma is the covariance matrix for the observed variables X and the latent variables UU, and we partition Σ\Sigma into matrices that quantify the relationships among the observed variables (ΣXX\Sigma_{XX}), between the observed variables and latent variables (ΣXU\Sigma_{XU} or ΣUX\Sigma_{UX}), and of the latent variables (ΣUU\Sigma_{UU}). In general, the data is generated with:

Xi1Ui1Np(ΣXUΣUU1Ui1,ΣXXΣXUΣUU1ΣUX), X_{i1} | U_{i1} \sim N_p(\Sigma_{XU}\Sigma^{-1}_{UU} U_{i1}, \Sigma_{XX} - \Sigma_{XU}\Sigma^{-1}_{UU}\Sigma_{UX}),

XitXi(t1),UitNp(AXi(t1)+ΣXUΣUU1Uit,ΣXXΣXUΣUU1ΣUX), X_{it} | X_{i(t-1)},U_{it} \sim N_p(AX_{i(t-1)} + \Sigma_{XU}\Sigma^{-1}_{UU} U_{it}, \Sigma_{XX} - \Sigma_{XU}\Sigma^{-1}_{UU}\Sigma_{UX}),

where 1in1 \le i \le n and 1tR1 \le t \le R.

Value

X

the generated data, which is a list with nn elements and each element is a matrix with RR rows and pp columns

truegraph

a matrix that encodes the conditional dependence relationships between sets of two observed variables

References

Jin, Y., Ning, Y., and Tan, K. M. (2020), ‘Exponential Family Graphical Models with Correlated Replicates and Unmeasured Confounders’, preprint available.

Examples

data <- generate_Gaussian(n = 50, R = 20, p = 30, l = 2, s = 2, sparsityA = 0.95,
sparsityobserved = 0.9, sparsitylatent = 0.2, lwb = 0.3, upb = 0.3, seed = 1)

[Package latentgraph version 1.1 Index]