View source: R/datacggm_tools.R
rcggm | R Documentation |
‘rcggm
’ function is used to produce one or more samples from a conditional Gaussian graphical model with censored and/or missing values.
rcggm(n, p, b0, X, B, Sigma, probl, probr, probna, ...)
n |
the number of samples required (optional, see below for a description). |
p |
the number of response variables (optional, see below for a description). |
b0 |
a vector of length |
X |
a matrix of dimension n x q used to model the expected values of the response variables (optional, see below for a description). |
B |
a matrix of dimension q x p used to specify the regression coefficients. If |
Sigma |
a positive-definite symmetric matrix specifying the covariance matrix of the response variables. Default is the identity matrix (optional, see below for a description). |
probl |
a vector giving the probabilities that the response variables are left-censored. |
probr |
a vector giving the probabilities that the response variables are right-censored. |
probna |
the probability that a response value is missing-at-random. By default ‘ |
... |
further arguments passed to the function ‘ |
‘The rcggm
’ function simulates a dataset from a conditional Gaussian graphical model with censored or missing values and returns an object of class ‘datacggm
’. Censoring values are implicitly specified using arguments probl
and probr
, that is, lo
and up
are computed in such a way that the average probabilities of left and right censoring are equal to probl
and probr
, respectively. Missing-at-random values are simulated using a Bernoulli distribution with probability probna
.
The dataset is simulated through the following steps:
lower and upper censoring values (lo
and up
) are computed according to the arguments probl
and probr
;
The function mvrnorm
is used to simulate one or more samples from the multivariate Gaussian distribution specified by the arguments b0
, X
, B
and Sigma
;
The response values that are outside of the interval [lo, up]
are replaced with the corresponding censoring values;
if probna
is greater than zero, then missing-at-random values are simulated using a Bernoulli distribution with probability probna
.
Model | n | p | b0 | X | B | Sigma | Gaussian distribution |
1 | x | x | Y ~ N(0, I) | ||||
2 | x | x | Y ~ N(0, Sigma) | ||||
3 | x | x | Y ~ N(b0, I) | ||||
4 | x | x | x | Y ~ N(b0, Sigma) | |||
5 | x | x | Y ~ N(XB, I) | ||||
6 | x | x | x | Y ~ N(XB, Sigma) | |||
7 | x | x | x | Y ~ N(b0 + XB, I) | |||
8 | x | x | x | x | Y ~ N(b0 + XB, Sigma) |
The previous table sums up the default setting of the multivariate Gaussian distribution used in step 2 (specified arguments are marked by the symbol ‘x
’). See also below for some examples.
rcggm
returns an object of class ‘datacggm
’. See datacggm
for further details.
Luigi Augugliaro (luigi.augugliaro@unipa.it)
Augugliaro L., Sottile G., Wit E.C., and Vinciotti V. (2023) <doi: 10.18637/jss.v105.i01>. cglasso: An R Package for Conditional Graphical Lasso Inference with Censored and Missing Values. Journal of Statistical Software 105(1), 1–58.
Augugliaro, L., Sottile, G., and Vinciotti, V. (2020a) <doi: 10.1007/s11222-020-09945-7>. The conditional censored graphical lasso estimator. Statistics and Computing 30, 1273–1289.
Augugliaro, L., Abbruzzo, A., and Vinciotti, V. (2020b) <doi: 10.1093/biostatistics/kxy043>. l1-Penalized censored Gaussian graphical model. Biostatistics 21, e1–e16.
datacggm
.
set.seed(123) n <- 100 p <- 3 q <- 2 b0 <- rep(1, p) X <- matrix(rnorm(n * q), n, q) B <- matrix(rnorm(q * p), q, p) Sigma <- outer(1:p, 1:p, function(i, j) 0.3^abs(i - j)) probl <- 0.05 probr <- 0.05 probna <- 0.05 # Model 1: Y ~ N(0, I) Z <- rcggm(n = n, p = p, probl = probl, probr = probr, probna = probna) summary(Z) # Model 2: Y ~ N(0, Sigma) Z <- rcggm(n = n, Sigma = Sigma, probl = probl, probr = probr, probna = probna) summary(Z) # Model 3: Y ~ N(b0, I) Z <- rcggm(n = n, b0 = b0, probl = probl, probr = probr, probna = probna) summary(Z) # Model 4: Y ~ N(b0, Sigma) Z <- rcggm(n = n, b0 = b0, Sigma = Sigma, probl = probl, probr = probr, probna = probna) summary(Z) # Model 5: Y ~ N(XB, I) Z <- rcggm(X = X, B = B, probl = probl, probr = probr, probna = probna) summary(Z) # Model 6: Y ~ N(XB, Sigma) Z <- rcggm(X = X, B = B, Sigma = Sigma, probl = probl, probr = probr, probna = probna) summary(Z) # Model 7: Y ~ N(b0 + XB, I) Z <- rcggm(b0 = b0, X = X, B = B, probl = probl, probr = probr, probna = probna) summary(Z) # Model 8: Y ~ N(b0 + XB, Sigma) Z <- rcggm(b0 = b0, X = X, B = B, Sigma = Sigma, probl = probl, probr = probr, probna = probna) summary(Z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.