1.実行環境
OS:windows10
R:Version 4.1.0
Rstudio:Version 1.4.1717
rstan:2.21.2
2.トラブル
WindowsでRstanを動かすと、最近、このようなエラーが出て止まってしまうことが多くて困っていました。
console
Warning in system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'C:/Rtools/mingw_/bin/g++' not found
Error in prep_call_sampler(object) :
the compiled object from C++ code for this model is invalid, possible reasons:
- compiled with save_dso=FALSE;
- compiled on a different platform;
- does not exist (created from reading csv files).
Warningは気にしなくてもよいみたいですが、Error in prep_call_sampler(object) :以下が出て止まります。
Ubuntu版RとWindows版Rの2つを使っていたのが悪かったのだろうかと思っていました。
3.解決!
作業ディレクトリの中のRdataファイルを削除して、Rstudioを再起動すると直りました。
Rの削除、再インストール、rstanのversionを落とす等もいろいろと試しましたが、最終的には実に簡単に直りました。