RStan Compilation error when there is indexing in generated quantities

104 views
Skip to first unread message

sreenath am

unread,
Nov 16, 2016, 3:47:47 PM11/16/16
to Stan users mailing list
Hi, 

I recently update to RStan 2.12.1 on a Windows 10 machine, with R-studio 1.0.44, R 3.3.2(64bit) and Rtools 3.3.x.
While trying to run models I successfully ran with stan 2.10 and 2.11 I got compilation error and a warning.
I recreate the error with the following logistic regression example:

model <- "
data{
  int N;
  int t;
  
  matrix[N,t] covMat;
  int y[N];
}
parameters{
vector[t] beta;
}
transformed parameters{
vector[N] xb;
xb = covMat*beta;
}
model{
y ~ bernoulli_logit(xb);
}
generated quantities{
vector[t] ew;
ew=exp(beta);
}
"
stm <- stan_model(model_code=model)

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Cannot export (default: symbol not defined
Cannot export 64): symbol not defined
Cannot export ANOMALY:: symbol not defined
Cannot export _ZZNK4stan11variational4adviIN60model346070b25b45_1b5d78b7f9957512a23992987098710a_namespace50model346070b25b45_1b5d78b7f9957512a23992987098710aENS0_16normal_meanfieldEN5boost6random23additive_combine_engineINS6_26linear_congruential_engineIjLj40014ELj0ELj2147483563EEENS8_IjLj40692ELj0ELj2147483399EEEEEE9calc_ELBOERKS4_R[0x7FF81DDF70E3]: symbol not defined
Cannot export is: symbol not defined
Cannot export meaningless: symbol not defined
Cannot export of: symbol not defined
Cannot export operand: symbol not defined
Cannot export size: symbol not defined
Cannot export use: symbol not defined
collect2.exe: error: ld returned 1 exit status
In addition: Warning message:
In if (nchar(CXX) > 0) return(TRUE) :
  the condition has length > 1 and only the first element will be used

I am getting the warning(in yellow) for all stan models. 
The error is a new one. I noticed that when I change the indexing to a numerical value (e.g: 3) there is no error in compilation. But the warning appears. 

Here is my R session info:

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

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

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

other attached packages:
[1] shinystan_2.2.1    shiny_0.14.2       rstan_2.12.1       StanHeaders_2.12.0 ggplot2_2.2.0      tidyr_0.6.0       
[7] dplyr_0.5.0        plyr_1.8.4         magrittr_1.5      

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7       colourpicker_0.2  shinyjs_0.8       base64enc_0.1-3   tools_3.3.2       xts_0.9-7         digest_0.6.10    
 [8] jsonlite_1.1      tibble_1.2        gtable_0.2.0      lattice_0.20-34   Matrix_1.2-7.1    DBI_0.5-1         parallel_3.3.2   
[15] gridExtra_2.2.1   stringr_1.1.0     gtools_3.5.0      dygraphs_1.1.1.3  htmlwidgets_0.8   stats4_3.3.2      grid_3.3.2       
[22] DT_0.2            inline_0.3.14     R6_2.2.0          reshape2_1.4.2    shinythemes_1.1.1 scales_0.4.1      threejs_0.2.2    
[29] htmltools_0.3.5   rsconnect_0.5     assertthat_0.1    mime_0.5          xtable_1.8-2      colorspace_1.3-0  httpuv_1.3.3     
[36] stringi_1.1.2     miniUI_0.1.1      lazyeval_0.2.0    munsell_0.4.3     markdown_0.7.7    zoo_1.7-13  

Please help, not able to continue my work. 

Thank you in advance. 

Best regards
Sreenath Madathil 


Ben Goodrich

unread,
Nov 16, 2016, 4:16:10 PM11/16/16
to Stan users mailing list
On Wednesday, November 16, 2016 at 3:47:47 PM UTC-5, sreenath am wrote:
I recently update to RStan 2.12.1 on a Windows 10 machine, with R-studio 1.0.44, R 3.3.2(64bit) and Rtools 3.3.x.
While trying to run models I successfully ran with stan 2.10 and 2.11 I got compilation error and a warning.
I recreate the error with the following logistic regression example:

Can you try stan() with the verbose = TRUE argument and paste the out?

Ben

sreenath am

unread,
Nov 16, 2016, 4:20:58 PM11/16/16
to stan-...@googlegroups.com
Hi Ben, 
Thank you for the prompt reply. 

Unfortunately its giving me the same error. (as below). 
The full verbose output it attached. 

Thanks
Sreenath


Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! Cannot export (default: symbol not defined
Cannot export 64): symbol not defined
Cannot export ANOMALY:: symbol not defined
Cannot export _ZZNK4stan11variational4adviIN60model346077df4c92_1b5d78b7f9957512a23992987098710a_namespace50model346077df4c92_1b5d78b7f9957512a23992987098710aENS0_16normal_meanfieldEN5boost6random23additive_combine_engineINS6_26linear_congruential_engineIjLj40014ELj0ELj2147483563EEENS8_IjLj40692ELj0ELj2147483399EEEEEE9calc_ELBOERKS4_R[0x7FF81DDF70E3]: symbol not defined
Cannot export is: symbol not defined
Cannot export meaningless: symbol not defined
Cannot export of: symbol not defined
Cannot export operand: symbol not defined
Cannot export size: symbol not defined
Cannot export use: symbol not defined
collect2.exe: error: ld returned 1 exit status
In addition: Warning message:
In if (nchar(CXX) > 0) return(TRUE) :
  the condition has length > 1 and only the first element will be used

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/GE72lsk4mMk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
Sreenath
CompilationError.txt

Ben Goodrich

unread,
Nov 16, 2016, 4:48:12 PM11/16/16
to Stan users mailing list
Does this yield 10?

fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
    return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 ) # should be 10

Ben

Daniel Lee

unread,
Nov 16, 2016, 4:57:54 PM11/16/16
to stan-users mailing list
Looks like the error is actually caused by boost. Can you make sure the bh package is up to date? I'm looking at the compiler error that you posted... this bit indicates it's from Boost: 
Cannot export _ZZNK4stan11variational4adviIN60model346077df4c92_1b5d78b7f9957512a23992987098710a_namespace50model346077df4c92_1b5d78b7f9957512a23992987098710aENS0_16normal_meanfieldEN5boost6random23additive_combine_engineINS6_26linear_congruential_engineIjLj40014ELj0ELj2147483563EEENS8_IjLj40692ELj0ELj2147483399EEEEEE9calc_ELBOERKS4_R[0x7FF81DDF70E3]: symbol not defined


--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.

sreenath am

unread,
Nov 16, 2016, 5:00:32 PM11/16/16
to stan-...@googlegroups.com
Hi, 

Yes, it does. 



--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/GE72lsk4mMk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
Sreenath

sreenath am

unread,
Nov 16, 2016, 5:06:31 PM11/16/16
to stan-...@googlegroups.com
Hi Daniel, 

The BH package i have is version 1.60.0-2. I think it's the latest version in CRAN.

I recently, re-installed both, R and R-studio and Rstan. 

Sree
--
Regards
Sreenath

sreenath am

unread,
Nov 17, 2016, 12:18:58 PM11/17/16
to stan-...@googlegroups.com
Hi, 

After trying different things. I tried R 32. bit version and the compilation error is not appearing in this version.
However, I still get the warning message, for any stan model I try to fit (including the 8 school example). 
Can someone help me to understand the warning message?

Warning message:
In if (nchar(CXX) > 0) return(TRUE) :
  the condition has length > 1 and only the first element will be used


Thanks
Sreenath



--
Regards
Sreenath

Ben Goodrich

unread,
Nov 17, 2016, 1:51:48 PM11/17/16
to Stan users mailing list
On Thursday, November 17, 2016 at 12:18:58 PM UTC-5, sreenath am wrote:
After trying different things. I tried R 32. bit version and the compilation error is not appearing in this version.
However, I still get the warning message, for any stan model I try to fit (including the 8 school example). 
Can someone help me to understand the warning message?

Warning message:
In if (nchar(CXX) > 0) return(TRUE) :
  the condition has length > 1 and only the first element will be used

It isn't that important but can you report the output of

rstan:::get_CXX()

Ben

sreenath am

unread,
Nov 17, 2016, 3:58:36 PM11/17/16
to stan-...@googlegroups.com
I am getting:

 "c:/Rtools/mingw_/bin/g++"

Sreenath

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/GE72lsk4mMk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards
Sreenath

sreenath am

unread,
Nov 18, 2016, 7:15:11 PM11/18/16
to Stan users mailing list
Finally after much investigation, I found where is the issue. 
Apparently, there is an incompatibility between Rstan and Trend Micro Internet Security. 
When I disabled the antivirus software, the error and the warning message are gone. 

Thank you very much to all respondents. Helped me a lot to figure out the issue fast. 

Shall I change this post to complete?

Best regards
Sreenath Madathil 
Reply all
Reply to author
Forward
0 new messages