| milr | R Documentation | 
Please refer to milr-package.
milr(
  y,
  x,
  bag,
  lambda = 0,
  numLambda = 20L,
  lambdaCriterion = "BIC",
  nfold = 10L,
  maxit = 500L
)
| y | a vector. Bag-level binary labels. | 
| x | the design matrix. The number of rows of  | 
| bag | a vector, bag id. | 
| lambda | the tuning parameter for LASSO-penalty.  If  | 
| numLambda | An integer, the maximum length of LASSO-penalty. in atuo-tunning mode 
( | 
| lambdaCriterion | a string, the used optimality criterion for tuning the  | 
| nfold | an integer, the number of fold for cross-validation to choose the optimal  | 
| maxit | an integer, the maximum iteration for the EM algorithm. The default is 500. | 
An object with S3 class "milr".
lambdaa vector of candidate lambda values.
cva vector of predictive deviance via nfold-fold cross validation
when lambdaCriterion = "deviance".
deviancea vector of deviance of candidate model for each candidate lambda value.
BICa vector of BIC of candidate model for each candidate lambda value.
best_indexan integer, indicates the index of the best model among candidate lambda values.
best_modela list of the information for the best model including deviance (not cv deviance), BIC, chosen lambda, coefficients, fitted values, log-likelihood and variances of coefficients.
set.seed(100)
beta <- runif(5, -5, 5)
trainData <- DGP(40, 3, beta)
testData <- DGP(5, 3, beta)
# default (not use LASSO)
milr_result <- milr(trainData$Z, trainData$X, trainData$ID)
coef(milr_result)      # coefficients
fitted(milr_result)                    # fitted bag labels
fitted(milr_result, type = "instance") # fitted instance labels
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID)                    # predicted bag labels
predict(milr_result, testData$X, testData$ID, type = "instance") # predicted instance labels
# use BIC to choose penalty (not run)
## Not run: 
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 bag labels
fitted(milr_result, type = "instance") # fitted instance labels
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID)                    # predicted bag labels
predict(milr_result, testData$X, testData$ID, type = "instance") # predicted instance labels
## End(Not run)
# use auto-tuning (not run)
## Not run: 
milr_result <- milr(trainData$Z, trainData$X, trainData$ID, lambda = -1, numLambda = 20)
coef(milr_result)      # coefficients
fitted(milr_result)                    # fitted bag labels
fitted(milr_result, type = "instance") # fitted instance labels
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID)                    # predicted bag labels
predict(milr_result, testData$X, testData$ID, type = "instance") # predicted instance labels
## End(Not run)
# use cv in auto-tuning (not run)
## Not run: 
milr_result <- milr(trainData$Z, trainData$X, trainData$ID, 
                    lambda = -1, numLambda = 20, lambdaCriterion = "deviance")
coef(milr_result)      # coefficients
fitted(milr_result)                    # fitted bag labels
fitted(milr_result, type = "instance") # fitted instance labels
summary(milr_result)   # summary milr
predict(milr_result, testData$X, testData$ID)                    # predicted bag labels
predict(milr_result, testData$X, testData$ID, type = "instance") # predicted instance labels
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.