mimi {mimi} | R Documentation |
main function: low-rank models to analyze and impute mixed and incomplete data frames with numeric, binary and discrete variables, and missing values
Description
main function: low-rank models to analyze and impute mixed and incomplete data frames with numeric, binary and discrete variables, and missing values
Usage
mimi(y, model = c("low-rank", "multilevel", "covariates"), x = NULL,
groups = NULL, var.type = c("gaussian", "binomial", "poisson"),
lambda1, lambda2, algo = c("mcgd", "bcgd"), maxit = 100,
alpha0 = NULL, theta0 = NULL, thresh = 1e-05, trace.it = F,
max.rank = NULL)
Arguments
y |
nxp matrix of observations |
model |
either one of "groups", "covariates" or "low-rank", indicating which model should be fitted |
x |
(np)xN matrix of covariates (optional) |
groups |
factor of length n indicating groups (optional) |
var.type |
vector of length p indicating the data types of the columns of y (gaussian, binomial or poisson) |
lambda1 |
positive number regularization parameter for nuclear norm penalty |
lambda2 |
positive number regularization parameter for l1 norm penalty |
algo |
type of algorithm to use, either one of "bcgd" (small dimensions, gaussian and binomial variables) or "mcgd" (large dimensions, poisson variables) |
maxit |
integer maximum number of iterations |
alpha0 |
vector of length N: initial value of regression parameter (optional) |
theta0 |
matrix of size nxp: initial value of interactions (optional) |
thresh |
positive number, convergence criterion |
trace.it |
boolean indicating whether convergence information should be printed |
max.rank |
integer, maximum rank of interaction matrix theta |
Value
A list with the following elements
alpha |
vector of main effects |
theta |
interaction matrix |
Examples
n = 6; p = 2
y1 <- matrix(rnorm(mean = 0, n * p), nrow = n)
y2 <- matrix(rnorm(mean = 0, n * p), nrow = n)
y3 <- matrix(rnorm(mean = 2, n * p), nrow = n)
y <- cbind(matrix(rnorm(mean = c(y1), n * p), nrow = n),
matrix(rbinom(n * p, prob = c(exp(y2)/(1+exp(y2))), size = 1), nrow = n),
matrix(rpois(n * p, lambda = c(exp(y3))), nrow = n))
var.type <- c(rep("gaussian", p), rep("binomial", p), rep("poisson", p))
idx_NA <- sample(1:(3 * n * p), size = round(0.01 * 3 * n * p))
y[idx_NA] <- NA
res <- mimi(y, model = "low-rank", var.type = var.type, lambda1 = 1, maxit=5)