2

查看http://www.bnlearn.com/documentation/man/arcops.html,删除弧的方法是使用该drop.arcs函数。

它似乎并没有放弃它

library(bnlearn)
data(learning.test)
res = gs(learning.test)

arcs(res)
     from to 
[1,] "A"  "B"
[2,] "A"  "D"
[3,] "B"  "A"
[4,] "B"  "E"
[5,] "C"  "D"
[6,] "F"  "E"

drop.arc(res, "A", "B")
arcs(res)
     from to 
[1,] "A"  "B"
[2,] "A"  "D"
[3,] "B"  "A"
[4,] "B"  "E"
[5,] "C"  "D"
[6,] "F"  "E"

但在调试日志中,它似乎有效。

drop.arc(res, "A","B",debug=T)
* dropping any arc between  A and B .
  > dropping any arc between A and B .
* (re)building cached information about node A.
* node A.
  > found child D.
  > found node C in markov blanket.
  > node A has 0 parent(s), 1 child(ren), 1 neighbour(s) and 2 nodes in the markov blanket.
...

这是一个问题R3.4.3吗?如何在检查循环时使用弧操作?我总是可以更换res$arcs桌子,但我希望能够检查周期。

> version
               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          4.3                         
year           2017                        
month          11                          
day            30                          
svn rev        73796                       
language       R                           
version.string R version 3.4.3 (2017-11-30)
nickname       Kite-Eating Tree     
> packageVersion('bnlearn')
[1] '4.3'
4

1 回答 1

0

帮助页面?drop.arcs

“所有函数都无形地返回 x 的更新副本。”

您必须将函数调用的结果分配给一个对象。所以试试

res2 = drop.arc(res, "A", "B") 
arcs(res2)
于 2021-08-20T18:22:52.557 回答