-1

I am using Max-min Markov blanket algorithm for variable selection in R from MXM package. Following is my code:

library(MXM)

dataset = read.table('data.txt', na.string = c("", "NA"), sep = '\t', header = FALSE)
dataset = dataset[, colSums(is.na(dataset)) == 0]
D = as.matrix(as.data.frame(lapply(dataset, as.numeric)))
target = read.table('class_num.txt')
target = c(target)

aa = mmmb(target, D, max_k = 3, threshold = 0.05, test = "testIndFisher", user_test = NULL, robust = FALSE, ncores = 2)

I am getting the following error:

Error in unique(as.numeric(target)) : 
(list) object cannot be coerced to type 'double'

According to the mmmb manual page my dataset D is a matrix of continuous value of dimension (95933 x 85) and my target is a vector of [0, 1] of size 95933.

Can someone help me understand the error?

MD Abid Hasan
  • 339
  • 1
  • 3
  • 15
  • Note that the MMMB algorithm has been shown to not always produce the true Markov blanket of a node. See the 2006 article "Towards scalable and data efficient learning of Markov boundaries" by Pena, Nilsson, Björkegren, Tegnér. Your alternatives would be the algorithms PCMB or IPC-MB (the latter is more efficient), if you can find any implementation though... – CamilB Jun 29 '19 at 09:20

1 Answers1

0

Got the solution: The target is a list instead of an array. The following line solved the issue:

target = array(as.numeric(unlist(target)))

Thanks!

MD Abid Hasan
  • 339
  • 1
  • 3
  • 15