| normal_block | R Documentation |
Fits a Normal-Block model, or a collection of them, by (variational) EM.
The arguments select the model: the family (model), whether the
clustering is known (blocks), whether the network is penalized
(sparsity) and whether Y is zero-inflated (zero_inflation).
normal_block(
data,
blocks,
sparsity = 0,
zero_inflation = FALSE,
control = NB_control(),
model = c("var", "mean")
)
data |
a NormalBlockData object, holding the responses (Y, n x p) and the covariates (X, n x d). |
blocks |
the clustering of the variables: a p x q indicator matrix
for a known clustering (e.g. |
sparsity |
the graphical-lasso penalty on Omega: |
zero_inflation |
whether to model an excess of exact zeros in Y. |
control |
a list of settings, built with |
model |
the model family: |
a fitted model (an R6 object, see the classes listed in the reference index), or a collection of fitted models.
## Variance-block models over a range of q
ex_data <- generate_normal_block_var_data(n = 100, p = 30, d = 1, q = 3)
data <- NormalBlockData$new(ex_data$Y, ex_data$X)
my_normal_block <- normal_block(data, blocks = 1:5)
plot(my_normal_block)
best <- my_normal_block$get_best_model("ICL")
plot(ex_data$Y, fitted(best)); abline(0, 1)
## the same with zero-inflation
ex_data_zi <- generate_normal_block_var_data(n = 50, p = 30, d = 1, q = 3,
kappa = rep(0.5, 30))
zidata <- NormalBlockData$new(ex_data_zi$Y, ex_data_zi$X)
my_zi_block <- normal_block(zidata, blocks = 3, zero_inflation = TRUE)
## a mean-block model (clustering in the mean rather than the covariance)
ex_mean <- generate_normal_block_mean_data(n = 50, p = 20, d = 1, q = 3)
mean_data <- NormalBlockData$new(ex_mean$Y, ex_mean$X)
my_mean_block <- normal_block(mean_data, blocks = 3, model = "mean")
coef(my_mean_block)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.