
‘rdatacggm
’ function is used to produce one or more samples from the specified censored Gaussian graphical model.
rdatacggm(n, mu, Sigma, probl, probr, lo, up, …)
the number of samples required.
a vector giving the means of the variables. By default all the expected vaules are equal to zero.
a positive-definite symmetric matrix specifying the covariance matrix of the variables. By default the identity matrix is used as covariance matrix.
a vector giving the probabilities that the random variables are left-censored.
a vector giving the probabilities that the random variables are right-censored.
a vector giving the left-censoring values.
a vector giving the right-censoring values.
futher arguments passed to the function ‘mvrnorm
’.
rdatacggm
returns an object with class ‘datacggm
’. See datacggm
for more 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:
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.
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
Augugliaro, L., Abbruzzo, A. and Vinciotti, V. (2018).
datacggm
, event
, cglasso
and the method function summary.datacggm
.
# 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