Description Usage Arguments Value Examples
View source: R/simulate_data.R
A partitioned inverse covariance (precision) matrix K is constructed as K := [K_X, K_{XL}; K_{XL}^T, K_L], where K_X is a p x p sparse matrix, K_{LX} is a p x h matrix connecting the h hidden variables to observed ones and K_L is a h x h diagonal matrix.
n samples are then drawn from a multivariate normal distribution: N(0, K^{-1}) and only the first p variables are observed.
This function is here to demonstrate the features of the package.
1 2 | generate.latent.ggm.data(n, p, h, sparsity = 0.02,
sparsity.latent = 0.7, outlier.fraction = 0)
|
n |
Number of samples. |
p |
Number of observed variables. |
h |
Number of hidden variables. |
sparsity |
Real between 0 and 1. The density of the sparse graph (encoded by K_X). |
sparsity.latent |
Real between 0 and 1. Probability of connection between any observed variable and any hidden variable (K_{LX}). |
outlier.fraction |
Fraction of the samples that should be drawn from a Cauchy distribution. The remaining ones are drawn from a multivariate normal with the same scale matrix. |
A list with keys:
n x p data matrix of observed variables.
(n+h) x p data matrix which also contains the hidden variables.
(n+h)x(n+h) matrix from which the data was sampled. Rows/Columns indexed by 1:p correspond to observed variables. The remaining h rows/cols are the hidden ones.
Realised sparsity of the precision matrix restricted to observed variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 | n <- 2000 # Number of samples
p <- 100 # Number of variables
h <- 5 # Number of hidden variables
sim.data <- generate.latent.ggm.data(n=n, p=p, h=h, outlier.fraction = 0.0,
sparsity = 0.02, sparsity.latent = 0.7)
true.S <- sim.data$precision.matrix[-((p+1):(p+h)),-((p+1):(p+h))] # The sparse matrix
observed.data <- sim.data$obs.data
# Generate data with 10 of samples drawn from a Cauchy
sim.data <- generate.latent.ggm.data(n=n, p=p, h=h, outlier.fraction = 0.1,
sparsity = 0.02, sparsity.latent = 0.7)
true.S <- sim.data$precision.matrix[-((p+1):(p+h)),-((p+1):(p+h))] # The sparse matrix
observed.data <- sim.data$obs.data
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.