Learn R Programming

cglasso (version 1.1.2)

rdatacggm: Simulate from a Censored Gaussian Graphical Model

Description

rdatacggm’ function is used to produce one or more samples from the specified censored Gaussian graphical model.

Usage

rdatacggm(n, mu, Sigma, probl, probr, lo, up, …)

Arguments

n

the number of samples required.

mu

a vector giving the means of the variables. By default all the expected vaules are equal to zero.

Sigma

a positive-definite symmetric matrix specifying the covariance matrix of the variables. By default the identity matrix is used as covariance matrix.

probl

a vector giving the probabilities that the random variables are left-censored.

probr

a vector giving the probabilities that the random variables are right-censored.

lo

a vector giving the left-censoring values.

up

a vector giving the right-censoring values.

futher arguments passed to the function ‘mvrnorm’.

Value

rdatacggm returns an object with class ‘datacggm’. See datacggm for more details.

Details

rdatacggm’ function simulates a dataset from a censored Gaussian graphical model and returns an object with class ‘datacggm’.

The dataset is simulated in two steps:

  1. in the first step the arguments n, mu, Sigma and are passed to the function mvrnorm to simulate one or more samples from the specified multivariate Gaussian distribution.

  2. in the second step, the values that are below or upper the censoring values are replaced.

The user can specify the censoring values in two equivalent ways. The simplest way is to use the arguments lo and up; a warning is produced if a full-observed dataset is simulated (see the last example). Alternatively, the censoring values can be implicitly specified using the arguments probl and probr. The \(j\)th lower censoring value, denoted by \(l_j\), is such that: $$\texttt{probl[j]} = \Pr\{X_j \le l_j\}.$$ In the same way, the \(j\)th upper censoring value, denoted by \(u_j\), is such that: $$\texttt{probr[j]} = \Pr\{X_j \ge u_j\}.$$

References

Augugliaro, L., Abbruzzo, A. and Vinciotti, V. (2018). \(\ell_1\)-Penalized gaussian graphical model. Biostatistics (to appear).

See Also

datacggm, event, cglasso and the method function summary.datacggm.

Examples

Run this code
# NOT RUN {
set.seed(123)

n <- 1000L
p <- 3L
mu <- rep(1L, p)
rho <- 0.3
Sigma <- outer(1L:p, 1L:p, function(i, j) rho^abs(i - j))

# simulating a dataset from a left-censored Gaussian graphical model
X <- rdatacggm(n = n, mu = mu, Sigma = diag(p), probl = 0.05)
# the same: X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, probl = 0.05, probr = 0)
# the same: X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, probl = 0.05, up = +Inf)
summary(X)

# simulating a dataset from a right-censored Gaussian graphical model
X <- rdatacggm(n = n, mu = mu, Sigma = diag(p), probr = 0.05)
# the same: X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, probr = 0.05, probl = 0)
# the same: X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, probr = 0.05, lo = -Inf)
summary(X)

# simulating a dataset from a censored Gaussian graphical model
X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, probr = 0.05, probl = 0.05)
summary(X)

# simulating a full observed dataset: a warning is produced
X <- rdatacggm(n = n, mu = mu, Sigma = Sigma, lo = -10, up = 10)
summary(X)
# }

Run the code above in your browser using DataLab