r语言,无法运行brms
在网上自己搜了很多,
Error in compileCode(f, code, language = language, verbose = verbose) :
C:\RBuildTools\4.2\x86_64-w64-mingw32.static.posix\bin/ld.exe: file4e8473fd1cc9.o:file4e8473fd1cc9.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\RBuildTools\4.2\x86_64-w64-mingw32.static.posix\bin/ld.exe: file4e8473fd1cc9.o:file4e8473fd1cc9.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\RBuildTools\4.2\x86_64-w64-mingw32.static.posix\bin/ld.exe: file4e8473fd1cc9.o:file4e8473fd1cc9.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\RBuildTools\4.2\x86_64-w64-mingw32.static.posix\bin/ld.exe: file4e8473fd1cc9.o:file4e8473fd1cc9.c
Error in sink(type = "output") : invalid connection
得知这一段报错很常见,与rstan与当前R的版本不匹配有关,但是我根据各种解决办法,包括更换R和Rtools的版本、安装cmdr等等,都无法解决。其中更换R的版本以后,我第一次换成了R4.0.0,把各种东西配置好以后,运行例子报错:
所以我又更换了R4.0.5版本,安装了rstan:
然后运行例子,这次显示:
一筹莫展了,其实没写出来的尝试还有很多,根据这些报错去官网还有可以找到的大部分帖子下面都找过解决办法,比如
https://zhuanlan.zhihu.com/p/577892365
这里提到的安装CmdStanR,通过原文给出的代码
install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
我无法下载:
但是我找到一个通过github下载的办法
# install.packages("remotes")
remotes::install_github("stan-dev/cmdstanr")
这一次下载成功了,然后根据指示检查C++工具链,并下载CmdStan
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan()
第一行运行以后:
> cmdstanr::check_cmdstan_toolchain(fix = TRUE)
The C++ toolchain required for CmdStan is setup properly!
但是后面要安装cmdstan的时候就会失败
> cmdstanr::install_cmdstan()
The C++ toolchain required for CmdStan is setup properly!
* Latest CmdStan release is v2.31.0
* Installing CmdStan v2.31.0 in C:/Users/cj/Documents/.cmdstan/cmdstan-2.31.0
* Downloading cmdstan-2.31.0.tar.gz from GitHub...
Error: Download of CmdStan failed. Please try again.
vpn已经试过,没有什么改变。
总结一下就是运行brms包中的函数时就会报错,Error in sink(type = "output") : invalid connection,换版本之类的尝试过,请问还有没有什么解决办法,或者说我之前列举的尝试还有什么地方做错了,求一个解决办法,谢谢了