R言語で統計的因果探索 lingamr パッケージ

bob3bob3
November 21, 2026

R言語で統計的因果探索 lingamr パッケージ

統計的因果探索を行う手法である Direct LiNGAM のためのR言語のパッケージ lingamr の紹介資料です。
2026年11月21日に行われたR研究集会(正式名称:統計数理研究所共同利用研究集会「データ解析環境Rの整備と利用」)にてLT発表しました。

bob3bob3

November 21, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

10 slides
  1. lingamrパッケージ • • lingamrは清水研究室のPythonパッケージ lingam をRに移植したものです。 CRANからインストールできます。 ◦ • Direct

    LiNGAM以外の手法も収録しています。 ◦ • install.packages("lingamr") 時系列、潜在交絡変数、高次元、混合データなどに対応します 日本語の解説も付いています。 ◦ vignette("lingamr-ja")
  2. 実行例 library(lingamr) # デモデータの生成 x <- generate_lingam_sample_6(n = 1000) #

    Direct LiNGAM の実行 model <- lingam_direct(x$data) # 推定された因果ダイアグラムの可視化 model$adjacency_matrix |> plot_adjacency( labels = colnames(model$adjacency_matrix), title = "Estimated Causal Structure (Direct LiNGAM)", rankdir = "TB", shape = "ellipse", fillcolor = "lightgreen" )
  3. 実行例: 総因果効果 ある変数を動かしたときの最終的な影響(直接効果と間接効果の合計)。単純な回帰分 析とは目的が異なる。 「x3を変化させるとx1がどう変化するか」に答えるのは総因果効果。 # x1に対する総因果効果 total_effects <- x$data

    |> estimate_all_total_effects(model) round(total_effects, 3) #> x0 x1 x2 x3 x4 x5 #> x0 0.000 0 0.000 3.033 0 0 #> x1 2.872 0 1.937 21.059 0 0 #> x2 0.000 0 0.000 5.993 0 0 #> x3 0.000 0 0.000 0.000 0 0 #> x4 7.910 0 -1.129 18.276 0 0 #> x5 4.015 0 0.000 12.179 0 0 # 単純な回帰分析との比較 lm_coefs <- coef(lm(x1 ~ ., data = x1k$data)) data.frame( variable = c("x0", "x2", "x3"), OLS_coefficient = round(lm_coefs[c("x0", "x2", "x3")], 3), total_causal_effect = round(total_effects["x1", c("x0", "x2", "x3")], 3) ) #> variable OLS_coefficient total_causal_effect #> x0 x0 3.237 2.872 #> x2 x2 1.965 1.937 #> x3 x3 0.014 21.059

More Decks by bob3bob3

Other Decks in Science