sambofra / bnstruct

R package for Bayesian Network Structure Learning
GNU General Public License v3.0
17 stars 11 forks source link

incoherent number of variables in raw dataset #23

Closed indu-bodala closed 2 years ago

indu-bodala commented 2 years ago

Hi,

I am facing problems while creating a BNDataset. I am reading a 9x80 matrix from a .csv file and this is supposed to contain 9 observations for 5 timesteps and 16 variables. Let's call this dbn_data.

I am reading it as follows: dbn_data <- read.csv("data_dbn.csv") dataset <- BNDataset(data = dbn_data, discreteness = rep(discon,5), node.sizes = rep(ns,5), variable.names = colnames(dbn_data), num.time.steps = 5, starts.from = 0, na.string.symbol = 'NA')

discon and ns are character and integer vectors respectively of size 16.

I am getting the following error: Error in validObject(x) : invalid class “BNDataset” object: incoherent number of variables in raw dataset

I have missing values in the data. Not sure is this is causing the problem. Am I supposed to do the imputation before creating BNDataset?

Thank you very much in advance.

indu-bodala commented 2 years ago

Found an issue with discreteness and corrected it. It works now!

albertofranzin commented 2 years ago

Ok, good. Please also note that the parameter name is variables, not variable.names.

indu-bodala commented 2 years ago

Yes, I corrected that. Then I got the error: Dataset contains values out of bounds for variables. That's when I realized the issue with discreteness.

Thanks!