市場創造型のイノベーション 書評:The Prosperity Paradox

2024/10/20

ノーベル物理学賞の対象としての機械学習  今年のストックホルムの物理学賞に、機械学習の分野への貢献に対してジョン・ホップフィールド氏と以前グーグルにいたトロントのジェフリー・ヒントン氏が選出された。  ACM、チューリング賞なら自然なのだが、コンピュータサイエンスの分野から物理学賞として選ばれるのは珍しい。ストックホルムの賞は物理学と化学と生理学の3種類しかないので、物理学的な考えがアルゴリズムに導入されているので物理学という枠組みが適用されるのであろう。それだけ機械学習の社会へのインパクトが大きいという ...

ReadMore

外国為替平衡操作のパラドックス

2024/9/20

 経済や金融の分野で、統計的な手法を使って市場を分析していると、実際の経済現象と一般に認識されている経済状況の間でパラドックスに出会うことがあります。  大規模金融緩和や長期間の金融緩和が経済活動の縮小を招くことや、通貨当局の外国為替市場介入により当局の意図とは逆方向に為替レートが推移することなどは、このサイトでも紹介しています。  ここでは以前、データの因果性を解析するツールの一つとしてcausal-learnや、CausalPyを紹介しました。パラドックスのように映る経済現象を正しく認知する上で因果性 ...

ReadMore

世界株式市場の混乱:外国為替市場介入による資金供与と相場操縦

2024/8/30

 2024年8月初旬、金融市場を揺るがす株式市場の乱高下が発生し、世界の主要な金融市場で混乱が見られました。東京市場では、8月5日に日経平均株価が12%を超える下落を記録しました。主要な原因と見られる背景が見過ごされているため、本稿でまとめておきます。  これは、端的に言えば犯罪収益によるドル円為替レートの相場操縦がもたらした株式市場の混乱です。 外為市場介入のリスク  前月の7月に財務省がドル売り市場介入を通じて、投機グループに資金を供与しました。建て玉余力を増加させた同グループがドル円の相場操縦を実施 ...

ReadMore

ヒューリスティックス:マーコヴィッツ・ポートフォリオ理論 対 不確実性

2024/8/22

 合理性の限界について検討を重ねていたハーバート・A・サイモンの時代は、ダニエル・カーネマン氏等の行動ファイナンスは経済学の主要な流れとはなっていませんでした。  サイモンは複雑系経済学の起源の一つとみなせますが、その時は複雑系という用語もありませんでした。 サイモンは人工的な現象(経済現象を含む)は、環境に従順であるという点で”環境依存性”を持っているとみなしていました。  サイモンの仕事を継承するような、現在、複雑系や行動心理学の分野で活動している人々は、不確実な状況での認知や予測に関して新しい知見を ...

ReadMore

マイナス金利 : ニューケインジアンの視点

2024/8/13

 多くのニューケインジアンのモデルでは、外因によりゼロ金利が想定されることで経済が流動性の罠に陥ることがあります。スウェーデン、デンマーク、スイス、ユーロ圏、日本で、深刻な不況に対応する非伝統的な金融政策として、金利を負の領域に導く政策が取られました。  欧州、米国ではコロナ・パンデミックからの回復と東欧での軍事侵攻を契機にしたグローバルなインフレーションに対応して、政策金利を引き上げました。日本は、最近マイナス金利政策を解除し、現在も量的緩和を継続しています。  量的緩和の効果に対しては、多数の研究報告 ...

ReadMore

書評:May Contain Lies -嘘を含んでいるかもしれない

2024/7/15

May Contain Lies: How stories, statistics and studies exploit our biases - and what we can do about it. Alex Edmans 嘘を含んでいるかもしれない:どのようにストーリー、統計、調査研究が私たちのバイアスにつけ込むか、私たちがそれについてできること。 嘘を含んでいるかもしれない  著者は、私たちの日々の生活に影響する誤った情報が氾濫している複雑な現代社会において、より賢明に考え、正しい判断を行う上 ...

ReadMore

現代のプロパガンダと量的緩和の陰影

2024/5/27

 ロシアが侵攻した地域で、老婆に物資を支給している映像を撮るロシア人を、ウクライナの現地の市民が動画撮影してSNSに投稿していました。ロシア兵は老婆に食料品を支給していましたが、その老婆は、解放している様子を演出するためにロシアから連れてきたエキストラでした。SNS動画には現地の市民がブーイングをしている様子が映されていました。  ロシアの国営放送では、そうしたエキストラを使った映像が放映され、ブチャでの惨状は放映されません。ロシア国内の市民が知るロシア語の報道は、現地を圧政から解放するロシア兵の映像です ...

ReadMore

causal-learnによる因果探索

2024/4/25

 【マネーサプライと物価上昇の因果推論】で、二つの時系列データ間のGranger因果性を調べました。ベクター自己回帰モデル(Vector Auto-Regression:VAR)を適用したものです。他にも、近年、新しい因果推論、因果探索アルゴリズムが提案されています。PythonやR上に実装された因果推論パッケージがAI関連技術に投資している企業や機関からリリースされています。  causalQueries, causalml, causal-learn等、【為替レートと地政学的リスク-割り込まれた時系列 ...

ReadMore

書評:Statistical Consequences of Fat Tails

2024/3/27

Statistical Consequences of Fat Tails Real World Preasymptotics, Epistemology, and Applications Nassim Nicholas Taleb Statistical Consequences of Fat Tails  タレブ氏の著書は、ビジネス書と一般向けの啓蒙書の印象がありますが、本書は統計の専門書になっています。  この著書は、不確実で複雑な現実社会をどのように生きるかという、著者のIncertoプロジェク ...

ReadMore

書評:BATTLEGROUND

2024/3/21

BATTLEGROUND Ten conflicts that explain the new Middle East. Christopher Phillips BATTLEGROUND - Ten conflicts that explain the new middle east  本書で示す中東は、14の異なる独立した国と地域からなります。著者は北アフリカのリビア、トルコも中東に拡張(モロッコ、アルジェリア、チェニジア)して論じています。イラン、イスラエル、トルコ、クルド等を除いて、多くの地域はア ...

ReadMore

システム

Apple Silicon M2 Mac の R環境設定 2

Rのインストール

Brewによるインストールを試しましたが、TCL/tkのバージョンの相違でコンパイルが止まりました。

後で、バイナリをインストールします。

brew install R
$ brew install R
==> Fetching dependencies for r: pkg-config, libpng, freetype, fontconfig, gettext, ninja, mpdecimal, ca-certificates, openssl@1.1, readline, sqlite, xz, python@3.11, meson, pcre2, glib, util-macros, xtrans, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, lzo, pixman, cairo, gmp, isl, mpfr, libmpc, lz4, zstd, gcc, jpeg-turbo, openblas and tcl-tk
==> Fetching pkg-config
Warning: Building pkg-config from source:
  The bottle (and many others) needs to be installed into /opt/homebrew.

==> Downloading https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar
######################################################################## 100.0%
==> Fetching libpng
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/manifests/1.6.39-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/blobs/sha256:27fb15928d0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching freetype
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/manifests/2.13.0_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/blobs/sha256:9dec5b349
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching fontconfig
Warning: Building fontconfig from source as the bottle needs:
- HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Users/xxxxxxxx/homebrew/Cellar)
- HOMEBREW_PREFIX: /opt/homebrew (yours is /Users/xxxxxxxx/homebrew)
==> Downloading https://www.freedesktop.org/software/fontconfig/release/fontconf
######################################################################## 100.0%
==> Fetching gettext
Warning: Building gettext from source as the bottle needs:
- HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Users/xxxxxxxx/homebrew/Cellar)
- HOMEBREW_PREFIX: /opt/homebrew (yours is /Users/xxxxxxxx/homebrew)
==> Downloading https://ftp.gnu.org/gnu/gettext/gettext-0.21.1.tar.gz
curl: (6) Could not resolve host: ftp.gnu.org
Warning: Problem : timeout. Will retry in 1 seconds. 3 retries left.
curl: (6) Could not resolve host: ftp.gnu.org                                 
Warning: Problem : timeout. Will retry in 2 seconds. 2 retries left.
curl: (6) Could not resolve host: ftp.gnu.org                                 
Warning: Problem : timeout. Will retry in 4 seconds. 1 retries left.
curl: (6) Could not resolve host: ftp.gnu.org                                 

Trying a mirror...
==> Downloading https://ftpmirror.gnu.org/gettext/gettext-0.21.1.tar.gz
==> Downloading from https://gnu.askapache.com/gettext/gettext-0.21.1.tar.gz
######################################################################## 100.0%

..
..
              .

                      省略
              .
..
..
==> Fetching ninja
==> Fetching openblas
==> Downloading https://ghcr.io/v2/homebrew/core/openblas/manifests/0.3.21
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openblas/blobs/sha256:5f2cdcefe
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Fetching tcl-tk
Warning: Building tcl-tk from source as the bottle needs:
- HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Users/xxxxxxxx/homebrew/Cellar)
- HOMEBREW_PREFIX: /opt/homebrew (yours is /Users/xxxxxxxx/homebrew)
==> Downloading https://github.com/andreas-kupries/critcl/archive/3.1.18.1.tar.g
==> Downloading from https://codeload.github.com/andreas-kupries/critcl/tar.gz/r
    # -#O=-#   #                                                              
==> Downloading https://downloads.sourceforge.net/project/tcllib/tcllib/1.21/tcl
==> Downloading from https://jaist.dl.sourceforge.net/project/tcllib/tcllib/1.21
######################################################################## 100.0%
==> Downloading https://core.tcl-lang.org/tcltls/uv/tcltls-1.7.22.tar.gz
######################################################################## 100.0%
==> Downloading https://downloads.sourceforge.net/project/tcl/Tcl/8.6.13/tk8.6.1
==> Downloading from https://jaist.dl.sourceforge.net/project/tcl/Tcl/8.6.13/tk8
######################################################################## 100.0%
==> Downloading https://downloads.sourceforge.net/project/incrtcl/%5Bincr%20Tcl_
==> Downloading from https://jaist.dl.sourceforge.net/project/incrtcl/%5Bincr%20
######################################################################## 100.0%
==> Downloading https://downloads.sourceforge.net/project/tcl/Tcl/8.6.13/tcl8.6.
==> Downloading from https://jaist.dl.sourceforge.net/project/tcl/Tcl/8.6.13/tcl
######################################################################## 100.0%
==> Fetching r
Warning: Building r from source as the bottle needs:
- HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Users/xxxxxxxx/homebrew/Cellar)
- HOMEBREW_PREFIX: /opt/homebrew (yours is /Users/xxxxxxxx/homebrew)
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/1b110
######################################################################## 100.0%
==> Downloading https://cran.r-project.org/src/base/R-4/R-4.2.3.tar.gz
######################################################################## 100.0%
Error: Your Command Line Tools are too outdated.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 14.1.

エラーが発生したので、以下のコマンドを実行します。

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

インストール後に、再度 Rのインストールを実行します。

==> ./configure --prefix=/Users/xxxxxxxx/homebrew/Cellar/tcl-tk/8.6.13_1 
==> make
Last 15 lines from /Users/xxxxxxxx/Library/Logs/Homebrew/tcl-tk/16.make:
1 error generated.
make: *** [itkUtil.o] Error 1
make: *** [itkOption.o] Error 1
1 error generated.
1 error generated.
make: *** [itkStubInit.o] Error 1
In file included from ./generic/itkArchetype.c:36:
In file included from ./generic/itkInt.h:24:
In file included from ./generic/itk.h:86:
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/tk.h:31:3: error: Tk 8.5 must be compiled with tcl.h from Tcl 8.5
#       error Tk 8.5 must be compiled with tcl.h from Tcl 8.5
        ^
make: *** [itkBase.o] Error 1
1 error generated.
make: *** [itkArchetype.o] Error 1

Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!

このエラーはTcl 8.5と他のバージョンのTclが同居している場合に発生するようです。

コンパイラはXcodeのライブラリヘッダ参照しています。

makeするTcl/tkのソースが8.6なので、整合性が取れません。

SDK Xcodeのライブラリを参照しており、移動して確認してみるとフレームワークのバージョン8.5にリンクが貼られています。

cd /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/

lrwxr-xr-x  1 root  wheel  70  3 24 23:46 tk.h -> ../../System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/tk.h

参照するヘッダのリンク先を変更すれば良さそうですが、少し手間がかかりそうです。

CRANから Rバイナリパッケージをインストール

CRANを参照すると、ARM Mac用のビルド済みパッケージがありました。

問題解決です。

Brewでコンパイルせず、CRANからパッケージをダウンロードしてインストールします。

CRANのWebサイト へアクセスし "R-4.2.3-arm64.pkg" をダウンロードします。

https://cran.r-project.org

ダウンロードしたファイルをダブルクリックすると、インストーラが起動します。

GUIインターフェイスに従ってインストールすれば完了です。

コマンドプロンプトからRと入力。

起動できました。

バージョンを確認してみます。

R --version

R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.

reposオプションでミラーサイトを指定します。

後は、必要なパッケージをインストールしてください。

options(repos="https://cran.ism.ac.jp/")
install.packages('必要なパッケージ')

パッケージをインストール中に以下の警告メッセージが出る場合があります。

 警告メッセージ: 
 doTryCatch(return(expr), name, parentenv, handler) で: 
   共有ライブラリ '/Library/Frameworks/R.framework/Resources/modules//R_X11.so' を読み込めません: 
  dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 0x0006): Library not loaded: /opt/X11/lib/libSM.6.dylib
  Referenced from: <A6A60F0C-DFA1-3218-B816-7CAADC1A4CD5> /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/modules/R_X11.so
  Reason: tried: '/opt/X11/lib/libSM.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/X11/lib/libSM.6.dylib' (no such file), '/opt/X11/lib/libSM.6.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libSM.6.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.1+12/Contents/Home/lib/server/libSM.6.dylib' (no such file) 
> install.packages('Quandl')
 URL 'https://cran.ism.ac.jp/bin/macosx/big-sur-arm64/contrib/4.2/Quandl_2.11.0.tgz' を試しています 
Content type 'application/x-gzip' length 68298 bytes (66 KB)

 X11の共有ライブラリが読み込めないとのことです。

 X11をインストールします。

以下のWebサイトへ移動します。

https://www.xquartz.org

XQuartz -2.8.5.pkg をダウンロードします。
インストール後に再度,Quandlのパッケージをインストールします。

install.packages('Quandl')
 URL 'https://cran.ism.ac.jp/bin/macosx/big-sur-arm64/contrib/4.2/Quandl_2.11.0.tgz' を試しています 
Content type 'application/x-gzip' length 68298 bytes (66 KB)
==================================================
downloaded 66 KB


 ダウンロードされたパッケージは、以下にあります 
 	/var/folders/z3/y2vb_4653kjcytsygg5bkv7w0000gn/T//RtmpbdtPcd/downloaded_packages 

他の有用なファイナンス関連のパッケージもCRANからインストールしてください。

-システム
-,