I have got a Bayesian network with nodes X1 to X5 and a dataframe with states as follows:
   X1  X2  X3  X4  X5
   yes yes no  yes no
   yes no  no  yes no
   no  yes yes yes yes
   yes no  no  no  yes
   etc.
I want to calculate the joint probability of each row using the pEvidence function in gRain (after setting the evidence). However, it is very slow to iterate line by line. Is there a way to calculate these probabilities quicker?
Edit: This is what I've done:
     summation=apply(dataframe,1,function(x)log(pEvidence(setEvidence(empbayesnet,
                                                nodes=c("X1","X2","X3","X4","X5"), 
                                                states=c(as.character(x[1]),
                                                         as.character(x[2]),
                                                         as.character(x[3]),
                                                         as.character(x[4]),
                                                         as.character(x[5])))))  
'empbayesnet' is the bayesian network which I'd like to calculate the joint probability from. Thanks!
