因果深層学習 meta-Learner, TARNet, CFRNet, DragonNet

2026/3/21

 因果推論において、処置の個別の効果を把握するのに、ITE(Indivisual Treatment Effect)あるいは、CATE(Conditional Average Treatment Effect)を計算します。伝統的な機械学習の方法を使って因果の効果を計算する場合は、対象となるデータに適合する機械学習モデル、たとえば、ツリーをもとにした方法やニューラルネットワークを使います。本稿ではNeyman-RubinのPOフレームワークを使って、バイナリの処置効果の推定のために、meta-learne ...

ReadMore

MMT信仰が招く"アリとキリギリス"の結末

2026/3/9

「潜在成長率に合わせて通貨を発行し、増えた分が政府支出となる」これは、MMTと日本でリフレ派と呼ばれる人々の主張を端的に示したものです。  MMTの理論的な背景は、貨幣を国家の創造物と捉えるくらいで、その他は主流派の経済学と大差ありません。彼らは”政府債務の拡大が自国通貨建てであるかぎり、信用リスクや通貨の信任の問題は発生せず”、”財政赤字を全く気にする必要はない”と主張します。 政府支出の制限 ー アリとキリギリス  MMTは単一の理論ではなく、貨幣に関するいくつかの考え方の集まったものです。日本で話題 ...

ReadMore

外為市場介入クレプトピア3:公金の行方

2026/2/18

 現在も日本の担当者がドル円為替レートの推移に関して介入を示唆する発言をすることがあります。  もし、実際には2026年1月23日に外国為替市場へ単独介入が実施されていた場合、どういうことが起きているかを明らかにしておきます。  what if ~ のCounterfactual推論と捉えてください。 外国為替市場ドル売り介入  外国為替市場への介入については、実際の処理はよく知られていません。図1を例に、どのように処理されているか見ていきましょう。 図1 ドル売り介入の場合  外国為替市場介入は、以下の ...

ReadMore

外為市場介入クレプトピア2:繁栄への月並みの経路

2026/2/5

1月23日のドル円為替市場  かつてある公的機関から事実とは異なる内容が、連日発表されていました。現在から、80年以上前のことです。  現在、2026年1月30日の発表によると、先月2025年12月29日から2026年1月28日までの外為市場介入はなかったことになっています。  1月23日の日銀総裁会見後のドル円為替レートの推移には、大きな建て玉の裁定取引の履歴が記録されています。ドル売りの投入資金は反対売買で全額決済されています。  数日前、1月20日に米国で長期金利が上昇しています。まとまった量の米国 ...

ReadMore

外為市場介入クレプトピア:美しい国、日本

2026/1/26

 クレプトピアは クレプトクラシー(Kleptocracy)とユートピア(Utopia)を組み合わせた造語です。Kleptocracyは権力者が国の富を奪うことを指します。  1月23日、日銀総裁の会見後に、ドル円レートが2円程シフトしていました。金融関係者の間でレートチェックがあったと噂になっていたようです。  夕方、公金を流用した資本による企業の社員が陽気に騒いでいたので、おそらく外国為替市場で通貨当局によるドル売り介入が実施されたのでしょう。  通貨当局の新しい担当者が、外為市場を経由して、また私的 ...

ReadMore

書評:BLACK WAVE

2026/1/10

Black Wave - Saudi Arabia , Iran And The Rivalry That Unravelled the Middle East Kim Ghattas BLACK WAVE - Saudi Arabia, Iran And The Rivalry That Unravelled The Middle East  2020年の出版物ですが、未読であり、価格がリーズナブルだったので購入しました。  サウジアラビアとイランのライバル関係を軸にイラン革命以後の中東の国際関係のパズ ...

ReadMore

do-Calculus: ベイジアン・ネットワークによるシナリオ分析

2026/1/25

 do-Calculusの概念を解説します。do-演算子(do-operator)と条件確率式で定義してあり、PearlのDAGを元にした因果推論の中心的な概念です。d-Calculusの三つのルールはd-separatorという概念を適用することで、ある確率分布が別の確率分布と等しいことを示すものです。直感的に把握するのは難しい概念であるかもしれません。DAGをイメージして把握した方が良いでしょう。  DAGで示した確率空間でノードの数が少なくなれば、同時確率分布、条件確率分布において計算が簡素化できま ...

ReadMore

企業が不祥事を招くコンテクストとは 書評:The Dark Pattern

2025/9/28

The Dark Pattern: The Hidden Dynamics of Corporate Scandals Palazzo Ph.D, Guido; Hoffrage Ph.D, Ulrich The Dark Pattern: The Hidden Dynamics of Corporate Scandals.  本書は良い人が悪事を働くことについて記されています。ある環境の下では、彼らは嘘をつき、詐欺に関与します。彼らの振る舞いを理解するために、著者らは彼らの性格の欠点に焦点を当てるだけで ...

ReadMore

投資ポートフォリオのストレス・テストーpgmpyベイジアン・ネットワークによるリスク評価

2025/8/6

地政学的リスク 原油価格とインフレーション  天然資源、特に原油価格を主要因に置いたインフレーションとポートフォリオを構成する各資産のストレス・テストのシナリオの一例を図示しています。ストレス・テストとして該当シナリオ1によるポートフォリオの損益を推定します。 図1 原油価格と地政学的リスクのシナリオ  中東の紛争による地政学的リスクの上昇、原油価格の変動は、必ずしも資産価格の下落に繋がりません。これは、資産価格に影響するまでに複数の経路があることが影響しています。  リスク・シナリオをDAG(Direc ...

ReadMore

書評:Autocracy,Inc.

2025/6/16

Autocracy,Inc. The Dictators Who Want to Run the World. Anne Applebaum Autocracy,Inc. The Dictators Who Want to Run the World.  Autocracy,Inc.とは著者の造語です。本書のテーマをわかりやすく表現しています。  Incは通常、Incorporated として会社組織の法人名に使います。xxx Inc.と略し会社名の終わりにつけます。統合した独裁国家、あるいは一体化した専 ...

ReadMore

システム

Apple Silicon M2 Mac の R環境設定1

anacondaからARMネイティブなディストリビューションがリリースされていたのでインストールしました。

ところが、インストール後にナビゲーターを起動すると、R Studioがパッケージに含まれていません。

ARM MAC 版の Anacondaには Rの処理環境はバンドルされていません。

別途、Rの環境をインストールすることにします。

Home Brewのインストール

x86版のBrewがインストール済みであれば外してから、ARM版をインストールします。

# uninstall x86_64 homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
# make sure you unalias "brew" if you aliased it with "arch"

# install arm64 homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# install wget (to make sure stuff is working)
brew install wget

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/Cellar
/opt/homebrew/Caskroom

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/Cellar /opt/homebrew/Caskroom
==> /usr/bin/sudo /bin/chmod ug=rwx /opt/homebrew/Cellar /opt/homebrew/Caskroom
==> /usr/bin/sudo /usr/sbin/chown xxxxxxxx /opt/homebrew/Cellar /opt/homebrew/Caskroom
==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/Cellar /opt/homebrew/Caskroom
==> /usr/bin/sudo /usr/sbin/chown -R xxxxxxxx:admin /opt/homebrew
==> /usr/bin/sudo /bin/mkdir -p /Users/xxxxxxxx/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/xxxxxxxx/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown -R xxxxxxxx /Users/xxxxxxxx/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 233534, done.
remote: Counting objects: 100% (119/119), done.
remote: Compressing objects: 100% (107/107), done.
remote: Total 233534 (delta 19), reused 80 (delta 12), pack-reused 233415
Receiving objects: 100% (233534/233534), 67.19 MiB | 255.00 KiB/s, done.
Resolving deltas: 100% (171421/171421), done.
From https://github.com/Homebrew/brew
 * [new branch]          master     -> origin/master
 * [new tag]             0.1        -> 0.1
 * [new tag]             0.2        -> 0.2
 * [new tag]             0.3        -> 0.3
 * [new tag]             0.4        -> 0.4
 * [new tag]             0.5        -> 0.5
 * [new tag]             0.6        -> 0.6
 * [new tag]             0.7        -> 0.7

  .
  .
 省略
  .
  .
  .

 * [new tag]             4.0.6      -> 4.0.6
 * [new tag]             4.0.7      -> 4.0.7
 * [new tag]             4.0.8      -> 4.0.8
 * [new tag]             4.0.9      -> 4.0.9
HEAD is now at d80f7ac48 Merge pull request #15052 from MikeMcQuaid/formulary_service
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

次にwgetをインストールします

brew install wget

$ brew install wget
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 2 taps (shivammathur/php and homebrew/core).
==> New Formulae
adr-viewer                               mailsy
agg                                      mariadb@10.10
aichat                                   mariadb@10.8
aicommits                                mariadb@10.9
aiven-client                             markdownlint-cli2
akku                                     marksman

  .
  .
  .
  省略
 .
  
lmfit                                    zf
luacheck                                 zlint
lucky-commit                             zls
m1ddc                                    zsh-autocomplete
macpine                                  zsh-autopair
==> Deleted Formulae
php@7.3 ✘

You have 52 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

エラーになりました。

以前のバージョンとマイグレーションするため、以下のコマンドを試します。

brew bundle dump

$ brew bundle dump
==> Tapping homebrew/bundle
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-bundle'...
remote: Enumerating objects: 7042, done.
remote: Counting objects: 100% (843/843), done.
remote: Compressing objects: 100% (154/154), done.
Receiving objects: 100% (7042/7042), 1.65 MiB | 340.00 KiB/s, done.
remote: Total 7042 (delta 739), reused 744 (delta 689), pack-reused 6199
Resolving deltas: 100% (4117/4117), done.
Tapped 1 command (99 files, 2MB).

次にhomebrewを別な方法でインストールします。

git clone https://github.com/Homebrew/brew homebrew

$ git clone https://github.com/Homebrew/brew homebrew
Cloning into 'homebrew'...
remote: Enumerating objects: 233534, done.
remote: Counting objects: 100% (75/75), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 233534 (delta 19), reused 36 (delta 12), pack-reused 233459
Receiving objects: 100% (233534/233534), 67.19 MiB | 333.00 KiB/s, done.
Resolving deltas: 100% (171421/171421), done.

eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet

$ brew update --force --quiet
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Tapping homebrew/core
Cloning into '/Users/xxxxxxxxx/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1442857, done.
remote: Counting objects: 100% (364/364), done.
remote: Compressing objects: 100% (185/185), done.
remote: Total 1442857 (delta 225), reused 306 (delta 179), pack-reused 1442493
Receiving objects: 100% (1442857/1442857), 556.64 MiB | 1.67 MiB/s, done.
Resolving deltas: 100% (1007537/1007537), done.
Tapped 2 commands and 6597 formulae (6,950 files, 611.9MB).

chmod -R go-w "$(brew --prefix)/share/zsh"

ライブラリのインストール

ライブラリ関係をインストールします。

ダウンロードするファイルを一時保存しておくためのディレクトリを作成します。

その中にarm64用のライブラリをダウンロードします。

#install arm64 homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

#install wget

brew install wget

# place for r-libs
mkdir ~/Downloads/libs-arm64/
# go there
cd ~/Downloads/libs-arm64
# grab'em from https://mac.r-project.org/libs-arm64/
for dl in $(curl -sS "https://mac.r-project.org/libs-arm64/" \
  | xmllint --html --xpath '//td/a[contains(@href, 'tar.gz')]/@href' 2>/dev/null - \
  | sed -e 's/ href="//g' -e 's/"/\n/g'); do wget https://mac.r-project.org/libs-arm64/${dl} ; done

# prime sudo
sudo ls ~/Downloads/libs-arm64
# extract'em
for gz in $(ls ~/Downloads/libs-arm64/*gz); do  
  sudo tar fvxz ${gz} -C /
done
64-darwin20.dmg
mac.r-project.org (mac.r-project.org) をDNSに問いあわせています... 169.60.149.197
mac.r-project.org (mac.r-project.org)|169.60.149.197|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 73110774 (70M) [application/octet-stream]
`emacs-27.1-app-arm64-darwin20.dmg' に保存中

emacs-27.1-app-arm6 100%[===================>]  69.72M   378KB/s 時間 2m 26s   

2023-03-25 07:25:16 (488 KB/s) - `emacs-27.1-app-arm64-darwin20.dmg' へ保存完了 [73110774/73110774]

--2023-03-25 07:25:17--  https://mac.r-project.org/libs-arm64/tcltk-8.6.11-xft-darwin20.4-arm64.pkg
mac.r-project.org (mac.r-project.org) をDNSに問いあわせています... 169.60.149.197
mac.r-project.org (mac.r-project.org)|169.60.149.197|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 8393736 (8.0M) [application/octet-stream]
`tcltk-8.6.11-xft-darwin20.4-arm64.pkg' に保存中

tcltk-8.6.11-xft-da 100%[===================>]   8.00M  2.08MB/s 時間 3.9s     

2023-03-25 07:25:21 (2.08 MB/s) - `tcltk-8.6.11-xft-darwin20.4-arm64.pkg' へ保存完了 [8393736/8393736]

--2023-03-25 07:25:21--  https://mac.r-project.org/libs-arm64/texinfo-6.7-darwin20.4-arm64.pkg
mac.r-project.org (mac.r-project.org) をDNSに問いあわせています... 169.60.149.197
mac.r-project.org (mac.r-project.org)|169.60.149.197|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 1495341 (1.4M) [application/octet-stream]
`texinfo-6.7-darwin20.4-arm64.pkg' に保存中

texinfo-6.7-darwin2 100%[===================>]   1.43M   259KB/s 時間 5.5s     

2023-03-25 07:25:28 (265 KB/s) - `texinfo-6.7-darwin20.4-arm64.pkg' へ保存完了 [1495341/1495341]

ダウンロードしたファイルを展開します。

# prime sudo
sudo ls ~/Downloads/libs-arm64
# extract'em
for gz in $(ls ~/Downloads/libs-arm64/*gz); do  
  sudo tar fvxz ${gz} -C /
done

x opt/R/arm64/bin/lzmore
x opt/R/arm64/bin/lzfgrep
x opt/R/arm64/bin/xzmore
x opt/R/arm64/bin/xzgrep
x opt/R/arm64/bin/lzma
x opt/R/arm64/bin/lzegrep
x opt/R/arm64/bin/xzdiff
x opt/R/arm64/
x opt/R/arm64/bin/
x opt/R/arm64/include/
x opt/R/arm64/lib/
x opt/R/arm64/pkg/
x opt/R/arm64/pkg/zeromq-4.3.2-darwin.20-arm64.list
x opt/R/arm64/lib/pkgconfig/
x opt/R/arm64/lib/libzmq.la
x opt/R/arm64/lib/libzmq.a
x opt/R/arm64/lib/pkgconfig/libzmq.pc
x opt/R/arm64/include/zmq_utils.h
x opt/R/arm64/include/zmq.h
x opt/R/arm64/bin/curve_keygen

開発環境のインストール

# grab r-devel
wget https://mac.r-project.org/big-sur/R-devel/arm64/R-devel.tar.gz
$ wget https://mac.r-project.org/big-sur/R-devel/arm64/R-devel.tar.gz
--2023-03-25 07:27:52--  https://mac.r-project.org/big-sur/R-devel/arm64/R-devel.tar.gz
mac.r-project.org (mac.r-project.org) をDNSに問いあわせています... 169.60.149.197
mac.r-project.org (mac.r-project.org)|169.60.149.197|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 79330143 (76M) [application/octet-stream]
`R-devel.tar.gz' に保存中

R-devel.tar.gz      100%[===================>]  75.65M   861KB/s 時間 1m 44s   

2023-03-25 07:29:37 (744 KB/s) - `R-devel.tar.gz' へ保存完了 [79330143/79330143]

圧縮ファイルを展開してインストールします。

# extract it
sudo tar fvxz R*.tar.gz -C /

x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/stats_package.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/Makefile.in
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/Complex.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/Lapack.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/Random.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/R_ext/eventloop.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/vg/valgrind.h
x Library/Frameworks/R.framework/Versions/4.4-arm64/PrivateHeaders/vg/memcheck.h
brew install libxml2 ccache libgit2 unixodbc
For pkg-config to find libxml2 you may need to set:
  export PKG_CONFIG_PATH="/Users/xxxxxxxx/homebrew/opt/libxml2/lib/pkgconfig"
==> ccache
To install symlinks for compilers that will automatically use
ccache, prepend this directory to your PATH:
  /Users/xxxxxxxx/homebrew/opt/ccache/libexec

If this is an upgrade and you have previously added the symlinks to
your PATH, you may need to modify it to the path specified above so
it points to the current version.

NOTE: ccache can prevent some software from compiling.
ALSO NOTE: The brew command, by design, will never use ccache.

 パスをとうすために以下の一行を~/.zshrc に追加します。

export PATH=/opt/R/arm64/bin:$PATH

vi ~/.zshrc

また、コマンドプロンプトからも同じ処理実行します。

# and also run it at the command prompt
export PATH=/opt/R/arm64/bin:$PATH

変更を読み込みます。

source ~/.zshrc

続きの設定は以下のリンクへ

-システム
-,