Maximum likelihood estimation of multiple-instance logistic regression with LASSO penalty

Description

Please refer to milr-package.

Usage

1
2
milr(y, x, bag, lambda = 0, lambdaCriterion = "BIC", nfold = 10,
  maxit = 500)

Arguments

y

a vector. Bag-level binary labels.

x

the design matrix. The number of rows of x must be equal to the length of y.

bag

a vector, bag id.

lambda

the tuning parameter for LASSO-penalty. If lambda is a real value number, then the milr fits the model based on this lambda value. Second, if lambda is vector, then the optimal lambda value would be be chosen based on the optimality criterion, lambdaCriterion. Finally, if lambda = -1, then the optimal lambda value would be chosen automatically. The default is 0.

lambdaCriterion

a string, the used optimality criterion for tuning the lambda value. It can be specified with lambdaCriterion = "BIC" or lambdaCriterion = "deviance".

nfold

an integer, the number of fold for cross-validation to choose the optimal lambda when lambdaCriterion = "deviance".

maxit

an integer, the maximum iteration for the EM algorithm.

Value

a list including deviance (not cv deviance), BIC, chosen lambda, coefficients, fitted values, log-likelihood and variances of coefficients.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
set.seed(100)
beta <- runif(5, -5, 5)
trainData <- DGP(70, 3, beta)
testData <- DGP(30, 3, beta)
# default (not use LASSO)
milr_result <- milr(trainData$Z, trainData$X, trainData$ID)
coef(milr_result)      # coefficients
fitted(milr_result)    # fitted values
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID) # predicted label

# use BIC to choose penalty
milr_result <- milr(trainData$Z, trainData$X, trainData$ID,
  exp(seq(log(0.01), log(50),length = 30)))
coef(milr_result)      # coefficients
fitted(milr_result)    # fitted values
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID) # predicted label

# use auto-tuning
milr_result <- milr(trainData$Z, trainData$X, trainData$ID, lambda = -1)
coef(milr_result)      # coefficients
fitted(milr_result)    # fitted values
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID) # predicted label

# use cv in auto-tuning
milr_result <- milr(trainData$Z, trainData$X, trainData$ID, 
                    lambda = -1, lambdaCriterion = "deviance")
coef(milr_result)      # coefficients
fitted(milr_result)    # fitted values
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID) # predicted label