Skip to contents

Fit a normal-block model with a variational or heuristic algorithm

Usage

normal_block(
  data,
  blocks,
  sparsity = 0,
  zero_inflation = FALSE,
  control = NB_control()
)

Arguments

data

contains the matrix of responses (Y, n x p) and the design matrix (X, n x d)."

blocks

either a integer (number of blocks), a vector of integer (list of possible number of block) or a p * Q matrix (for indicating block membership when its known)

sparsity

either TRUE to run the optimization for different sparsity penalty values OR float to run model with a single sparsity penalty value

zero_inflation

boolean to indicate if Y is zero-inflated and adjust fitted model as a consequence

control

a list-like structure for detailed control on parameters should be generated with NB_control().

Value

an R6 object with one of the NB classes

Examples

## Normal Data
ex_data <- generate_normal_block_data(n=50, p=50, d=1, Q=3)
data <- NBData$new(ex_data$Y, ex_data$X)
my_normal_block <- normal_block(data, blocks = 1:6)
#> Fitting a diagonal normal-block model with unknown Q 
#> 	number of blocks = 1           
	number of blocks = 2           
	number of blocks = 3           
	number of blocks = 4           
	number of blocks = 5           
	number of blocks = 6           

#> DONE
if (FALSE) { # \dontrun{
my_normal_block$plot(c("deviance", "BIC", "ICL"))
Y_hat <- my_normal_block$get_best_model()$fitted
plot(data$Y, Y_hat, log = "xy"); abline(0,1)
} # }
## Normal Data with Zero Inflation
ex_data_zi <- generate_normal_block_data(n=50, p=50, d=1, Q=3, kappa = rep(0.5,50))
zidata <- NBData$new(ex_data_zi$Y, ex_data_zi$X)
my_normal_block <- normal_block(zidata, blocks = 1:6, zero_inflation = TRUE)
#> Fitting a diagonal normal-block model with unknown Q 
#> 	number of blocks = 1           
	number of blocks = 2           
	number of blocks = 3           
	number of blocks = 4           
	number of blocks = 5           
	number of blocks = 6           

#> DONE