Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译错误,未创建函数/方法!对于brms模型_C++_R_Data Modeling_Stan_Rstan - Fatal编程技术网

C++ 编译错误,未创建函数/方法!对于brms模型

C++ 编译错误,未创建函数/方法!对于brms模型,c++,r,data-modeling,stan,rstan,C++,R,Data Modeling,Stan,Rstan,我又犯了这个错误。但与以前不同的是,现在以下测试有效: fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , ' return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ; ' ) fx( 2L, 5 ) # returns 10 as should be 以下是我的会话信息: sessionInfo() R version 3.5.0 (2018-04-23)

我又犯了这个错误。但与以前不同的是,现在以下测试有效:

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 ) # returns 10 as should be
以下是我的会话信息:

sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] rstudioapi_0.8.0.9000 brms_2.5.0           
[3] ggplot2_3.0.0         Rcpp_0.12.19         

loaded via a namespace (and not attached):
 [1] mvtnorm_1.0-8        lattice_0.20-35     
 [3] gtools_3.8.1         zoo_1.8-4           
 [5] assertthat_0.2.0     digest_0.6.18       
 [7] mime_0.6             R6_2.3.0            
 [9] plyr_1.8.4           backports_1.1.2     
[11] ggridges_0.5.1       stats4_3.5.0        
[13] coda_0.19-2          colourpicker_1.0    
[15] pillar_1.3.0         rlang_0.2.2         
[17] lazyeval_0.2.1       miniUI_0.1.1.1      
[19] Matrix_1.2-14        DT_0.4              
[21] shinythemes_1.1.1    shinyjs_1.0         
[23] stringr_1.3.1        htmlwidgets_1.3     
[25] loo_2.0.0            igraph_1.2.2        
[27] munsell_0.5.0        shiny_1.1.0         
[29] rstan_2.17.4         compiler_3.5.0      
[31] httpuv_1.4.5         pkgconfig_2.0.2     
[33] base64enc_0.1-3      rstantools_1.5.1    
[35] htmltools_0.3.6      tidyselect_0.2.5    
[37] tibble_1.4.2         gridExtra_2.3       
[39] threejs_0.3.1        matrixStats_0.54.0  
[41] crayon_1.3.4         dplyr_0.7.6         
[43] withr_2.1.2          later_0.7.5         
[45] grid_3.5.0           nlme_3.1-137        
[47] xtable_1.8-3         gtable_0.2.0        
[49] magrittr_1.5         StanHeaders_2.18.0  
[51] scales_1.0.0         stringi_1.1.7       
[53] reshape2_1.4.3       promises_1.0.1      
[55] bindrcpp_0.2.2       dygraphs_1.1.1.6    
[57] xts_0.11-1           tools_3.5.0         
[59] glue_1.3.0           markdown_0.8        
[61] shinystan_2.5.0      purrr_0.2.5         
[63] crosstalk_1.0.0      rsconnect_0.8.8     
[65] abind_1.4-5          parallel_3.5.0      
[67] inline_0.3.15        colorspace_1.3-2    
[69] bridgesampling_0.5-2 bayesplot_1.6.0     
[71] bindr_0.1.1          Brobdingnag_1.2-6 
如果有任何想法可以解决这个问题,我将不胜感激。

提供了使用
Stan
拟合贝叶斯模型的例程<代码> Stan < /代码>是一个C++库,它提供了定义贝叶斯模型的概率语言。然后将这些模型解析并用Stan语言表示为C++代码,然后将其编译成可执行程序。p>

这样简单地说,使用<代码> BRMS 的一个关键要求是C++编译器,它编译你的模型成为可执行程序。您的错误表明缺少后者

brms
GitHub:

因为BRMS是基于Stan的,所以需要C++编译器。程序RoToes(On on)附带一个用于Windows的C++编译器。在Mac上,您应该安装Xcode。有关如何运行编译器的更多说明,请参阅上的“先决条件”部分


您可以通过直接安装
Rtools

Hi@毛里求斯,您可以看到我的sessioninfo,我有这些。在安装RStan之前,我遵循了您提供的这些链接的说明。此外,当我运行
install.packages(“Rtools”)
时,我得到以下错误:
在install.packages中将程序包安装到'C:/…R/win library/3.4'(因为'lib'未指定)警告:程序包'Rtools'不可用(对于R版本3.4.2)
@Krantz我明白了。看来我弄错了(正如我所说,我不是Windows的人)<代码>Rtools不是常规的CRAN包。您需要直接从安装
Rtools
。确保选择了正确的版本。然后退出并重新启动R,然后重试。谢谢。让我试试,我会告诉你最新的结果。在此安装Rtools后,我按照中的说明进行了操作,但最后一步不起作用。此代码
fx(2L,5)
#应该是10,但给出了此错误:
fx(2L,5)中的错误:找不到函数“fx”
@Krantz-Hmm。我不确定问题出在哪里。Did
install.packages(“rstan”,repos=”https://cloud.r-project.org/“,dependencies=TRUE)
finish而不出错吗?如果
install.packages(…)
失败,则只需从源代码安装。安装后,不要忘记退出并重新启动R。然后键入
fx
`Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/.../Documents/R/win-library/3.5/BH/include/boost/config.hpp:39:0,
                 from C:/Users/.../Documents/R/win-library/3.5/BH/include/boost/math/tools/config.hpp:13,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/var.hpp:7,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:12,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/stan/math.hpp:4,
                 from C:/Users/.../Documents/R/win-library/3.5/StanHeaders/include/src/stan
In addition: Warning messages:
1: In rstan::stan_model(model_code = x$model, save_dso = save_dso) :
  StanHeaders version is ahead of rstan version; update to latest rstan
2: In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-3.5.1/bin/x64/R CMD SHLIB file110c1cb656fa.cpp 2> file110c1cb656fa.cpp.err.txt' had status 1 `
sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] rstudioapi_0.8.0.9000 brms_2.5.0           
[3] ggplot2_3.0.0         Rcpp_0.12.19         

loaded via a namespace (and not attached):
 [1] mvtnorm_1.0-8        lattice_0.20-35     
 [3] gtools_3.8.1         zoo_1.8-4           
 [5] assertthat_0.2.0     digest_0.6.18       
 [7] mime_0.6             R6_2.3.0            
 [9] plyr_1.8.4           backports_1.1.2     
[11] ggridges_0.5.1       stats4_3.5.0        
[13] coda_0.19-2          colourpicker_1.0    
[15] pillar_1.3.0         rlang_0.2.2         
[17] lazyeval_0.2.1       miniUI_0.1.1.1      
[19] Matrix_1.2-14        DT_0.4              
[21] shinythemes_1.1.1    shinyjs_1.0         
[23] stringr_1.3.1        htmlwidgets_1.3     
[25] loo_2.0.0            igraph_1.2.2        
[27] munsell_0.5.0        shiny_1.1.0         
[29] rstan_2.17.4         compiler_3.5.0      
[31] httpuv_1.4.5         pkgconfig_2.0.2     
[33] base64enc_0.1-3      rstantools_1.5.1    
[35] htmltools_0.3.6      tidyselect_0.2.5    
[37] tibble_1.4.2         gridExtra_2.3       
[39] threejs_0.3.1        matrixStats_0.54.0  
[41] crayon_1.3.4         dplyr_0.7.6         
[43] withr_2.1.2          later_0.7.5         
[45] grid_3.5.0           nlme_3.1-137        
[47] xtable_1.8-3         gtable_0.2.0        
[49] magrittr_1.5         StanHeaders_2.18.0  
[51] scales_1.0.0         stringi_1.1.7       
[53] reshape2_1.4.3       promises_1.0.1      
[55] bindrcpp_0.2.2       dygraphs_1.1.1.6    
[57] xts_0.11-1           tools_3.5.0         
[59] glue_1.3.0           markdown_0.8        
[61] shinystan_2.5.0      purrr_0.2.5         
[63] crosstalk_1.0.0      rsconnect_0.8.8     
[65] abind_1.4-5          parallel_3.5.0      
[67] inline_0.3.15        colorspace_1.3-2    
[69] bridgesampling_0.5-2 bayesplot_1.6.0     
[71] bindr_0.1.1          Brobdingnag_1.2-6