Closed edd3x closed 4 years ago
It seems it is a bug. Can you give more information to reproduce it? At least the header file, some rows of the data file, and the commands you are using.
Thanks for the quick response please find a zipped sample data and script attached. Very Great Library BNStruct, thanks
Sorry, I don't see where or how you use the data. Can you please provide a minimal example?
ScriptData.zip Very sorry I added the wrong script please see attached
Hello Alberto, Please have you been able to run the sample code, with data provided successfully without the error. I have also realised that you don't have examples codes for cases that involve the use of continuous variables. Thank you
I managed to reproduce the error. I'm looking into it, I'll let you know as soon as I have the chance,
Hello edd3x, the problem you were having should be fixed now. Can you please check whether it's working?
Hi @albertofranzin , I was just running the code provided by @edd3x with no modification of the code and I ran into a similar error: Error in if (levels[i] == 0) { : missing value where TRUE/FALSE needed
Hi,
in that example there is a problem with the layering provided: (4,2,3,5,1,1,1,1)
essentially tries to force a reverse time dependency, the error may arise from there.
You can start with this code (I removed the bootstrap part, for speed of execution):
library(bnstruct)
df1 = read.csv('Weekly_Lag2_Garissa_Sample2copy.csv')
headers1 = c('LST_t0', 'Rainfall_t0', 'SoilMoist_t0', 'VCI_t0','LST_t1', 'Rainfall_t1', 'SoilMoist_t1', 'VCI_t1')
sub_df1 = df1[,headers1]
quants1 = c(5, 5, 5, 5, 5, 5, 5,5)
bn_data1 = BNDataset(data=sub_df1,
discreteness=rep('C',8),
variables = headers1,
node.sizes = c(5,5,5,5,5,5,5,5))
layers = c(1,1,1,1,2,2,2,2)
net5 = learn.network(bn_data1, algo = "sem",
use.imputed.data = FALSE,
bootstrap=FALSE,
layering=layers)
This code works fine for me. If it doesn't for you, please let me know providing as much information as possible.
You can then try to reintroduce the bootstrap and see if there is an error; also in that case, please let me know.
Please I keep this error when I try to learn structure with SEM algorithm
Error in if (obs.val >= quantiles[[obs.var]][node.sizes[obs.var]]) { : missing value where TRUE/FALSE needed
Can you tell me what I am doing wrong, I am using continuous variables with 30% missing data.