## Loading required package: flexmix
## Loading required package: lattice
## Loading required package: Matrix

simulate data to test the algorithm

set.seed(123)
n = 400
ICD = c(rpois(n/4,10), rpois(n/4,1), rep(0,n/2) )
NLP = c(rpois(n/4,10), rpois(n/4,1), rep(0,n/2) )
mat = Matrix(data=cbind(ICD,NLP),sparse = TRUE)
note = Matrix(rpois(n,10)+5,ncol=1,sparse = TRUE)
res = MAP(mat = mat,  note=note)
## ####################### 
## MAP only considers pateints who have note count data and
##         at least one nonmissing variable!
## ####
## Here is a summary of the input data:
## Total number of patients: 400 
##   ICD NLP note Freq
## 1 YES YES  YES  400
## ####
head(res$scores)
## 6 x 1 sparse Matrix of class "dgCMatrix"
##               
## [1,] 0.9174454
## [2,] 0.9214842
## [3,] 0.9222160
## [4,] 0.9219585
## [5,] 0.9205031
## [6,] 0.9221740
res$cut.MAP
## [1] 0.2824703