kurowasan/GraN-DAG

The Pruning Method Returns Zeros Matrix

Closed this issue · 1 comments

Hi there,

Sorry for bothering again, I am implementing the Pruning module solely (simply pass the data matrix and estimated DAG into the def cam_pruning_). Logically, this should work right? But it returns all Zeros matrix which mean this function prunes all the edges. (All the R dependencies are installed and the CAM.R can be perform without any problem).

After then, I switch to Rscript for implementation. I save the data matrix and estimated DAG matrix. Then do: pruned_dag <- pruning(dataset, dag, pruneMethod = selGam, pruneMethodPars = list(cutOffPVal = 0.001, numBasisFcts = 10), output=TRUE).

However, it returns:
pruning variable: 1
considered parents:
pruning variable: 2
considered parents:
pruning variable: 3
considered parents:
pruning variable: 4
considered parents:
pruning variable: 5
considered parents:
pruning variable: 6
considered parents:
pruning variable: 7
considered parents:
pruning variable: 8
considered parents:
pruning variable: 9
considered parents:
pruning variable: 10
considered parents:

Screen Shot 2021-08-18 at 5 03 57 pm

which means it doesn't consider any parents nodes. Any idea about it? Very much appreciate for any reply if possible.

I just found where the problem is!!! When considering the parents' nodes, the original code is "parents <- which(G[,I]==1)", but I pass through the weighted adjacency matrix whose value is not necessarily being "1"! So I simply change the above into "parents <- which(G[,i]!=0)". Then magic appears!!!

If anyone else wanna implement the Pruning Method solely and meet this kind of problem, can refer to my solution!