Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with the experimental version of 2.26 from PR #887 #899

Open
5 tasks
rok-cesnovar opened this issue Jan 20, 2021 · 151 comments
Open
5 tasks

Issues with the experimental version of 2.26 from PR #887 #899

rok-cesnovar opened this issue Jan 20, 2021 · 151 comments

Comments

@rok-cesnovar
Copy link
Member

#887 is huge and I think the PR thread will eventually become impossible to follow. So I am opening this issue where you can post anything that is missing in the alpha 2.26 version.

Thanks @hsbadr for working on this massive pull request!

I think the checklist for making this happen is as follows:

  • Check that it works for the early-adopters/devs on all OS-es for R4.x (R-release)

  • Check that it works for the early-adopters/devs on all OS-es for R3.x (R-oldrel)

I think after this we can merge the PR and deal with smaller issues later.

  • Make a beta-call on Discourse for other users with a disclaimer that it might break other packages that depend on rstan.

  • Hash out issues after the beta call

  • Try to get this to CRAN - this is where my knowledge stops. I expect this is where the "fun" will start.

@cdriveraus
Copy link

so, the stanc() function seems? broken, in that it requires a file argument when, if you use the model_code argument, file should not be needed.

@hsbadr
Copy link
Member

hsbadr commented Jan 20, 2021

so, the stanc() function seems? broken, in that it requires a file argument when, if you use the model_code argument, file should not be needed.

stanc() interface and arguments didn't change. Can you provide a reproducible example?

@cdriveraus
Copy link

cdriveraus commented Jan 20, 2021

library(rstan)
st <- '
functions{
 real plus(real a){
 return a + 1;
 }
}
'

testcpp <- stanc(model_code = st)

@hansvancalster
Copy link

Updated:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

I installed using the above and then tried the following on my system (session info included below). This now seems to work 👍 Thank you @hsbadr !
Note that this is with the "broken" CRAN version of RcppParallel installed (see session info).

library(rstan)
#> Warning: package 'rstan' was built under R version 4.0.3
#> Loading required package: StanHeaders
#> Warning: package 'StanHeaders' was built under R version 4.0.3
#> rstan (Version 2.26.0.9000, GitRev: 2e1f913d3ca3)
#> For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores()).
#> To avoid recompilation of unchanged Stan programs, we recommend calling
#> rstan_options(auto_write = TRUE)
#> Do not specify '-march=native' in 'LOCAL_CPPFLAGS' or a Makevars file
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- sampling(m, iter = 100)
#> 
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 1.1e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: WARNING: There aren't enough warmup iterations to fit the
#> Chain 1:          three stages of adaptation as currently configured.
#> Chain 1:          Reducing each adaptation stage to 15%/75%/10% of
#> Chain 1:          the given number of warmup iterations:
#> Chain 1:            init_buffer = 7
#> Chain 1:            adapt_window = 38
#> Chain 1:            term_buffer = 5
#> Chain 1: 
#> Chain 1: Iteration:  1 / 100 [  1%]  (Warmup)
#> Chain 1: Iteration: 10 / 100 [ 10%]  (Warmup)
#> Chain 1: Iteration: 20 / 100 [ 20%]  (Warmup)
#> Chain 1: Iteration: 30 / 100 [ 30%]  (Warmup)
#> Chain 1: Iteration: 40 / 100 [ 40%]  (Warmup)
#> Chain 1: Iteration: 50 / 100 [ 50%]  (Warmup)
#> Chain 1: Iteration: 51 / 100 [ 51%]  (Sampling)
#> Chain 1: Iteration: 60 / 100 [ 60%]  (Sampling)
#> Chain 1: Iteration: 70 / 100 [ 70%]  (Sampling)
#> Chain 1: Iteration: 80 / 100 [ 80%]  (Sampling)
#> Chain 1: Iteration: 90 / 100 [ 90%]  (Sampling)
#> Chain 1: Iteration: 100 / 100 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 0 seconds (Warm-up)
#> Chain 1:                0 seconds (Sampling)
#> Chain 1:                0 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 3e-06 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.03 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2: 
#> Chain 2: 
#> Chain 2: WARNING: There aren't enough warmup iterations to fit the
#> Chain 2:          three stages of adaptation as currently configured.
#> Chain 2:          Reducing each adaptation stage to 15%/75%/10% of
#> Chain 2:          the given number of warmup iterations:
#> Chain 2:            init_buffer = 7
#> Chain 2:            adapt_window = 38
#> Chain 2:            term_buffer = 5
#> Chain 2: 
#> Chain 2: Iteration:  1 / 100 [  1%]  (Warmup)
#> Chain 2: Iteration: 10 / 100 [ 10%]  (Warmup)
#> Chain 2: Iteration: 20 / 100 [ 20%]  (Warmup)
#> Chain 2: Iteration: 30 / 100 [ 30%]  (Warmup)
#> Chain 2: Iteration: 40 / 100 [ 40%]  (Warmup)
#> Chain 2: Iteration: 50 / 100 [ 50%]  (Warmup)
#> Chain 2: Iteration: 51 / 100 [ 51%]  (Sampling)
#> Chain 2: Iteration: 60 / 100 [ 60%]  (Sampling)
#> Chain 2: Iteration: 70 / 100 [ 70%]  (Sampling)
#> Chain 2: Iteration: 80 / 100 [ 80%]  (Sampling)
#> Chain 2: Iteration: 90 / 100 [ 90%]  (Sampling)
#> Chain 2: Iteration: 100 / 100 [100%]  (Sampling)
#> Chain 2: 
#> Chain 2:  Elapsed Time: 0 seconds (Warm-up)
#> Chain 2:                0 seconds (Sampling)
#> Chain 2:                0 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 2e-06 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.02 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3: 
#> Chain 3: 
#> Chain 3: WARNING: There aren't enough warmup iterations to fit the
#> Chain 3:          three stages of adaptation as currently configured.
#> Chain 3:          Reducing each adaptation stage to 15%/75%/10% of
#> Chain 3:          the given number of warmup iterations:
#> Chain 3:            init_buffer = 7
#> Chain 3:            adapt_window = 38
#> Chain 3:            term_buffer = 5
#> Chain 3: 
#> Chain 3: Iteration:  1 / 100 [  1%]  (Warmup)
#> Chain 3: Iteration: 10 / 100 [ 10%]  (Warmup)
#> Chain 3: Iteration: 20 / 100 [ 20%]  (Warmup)
#> Chain 3: Iteration: 30 / 100 [ 30%]  (Warmup)
#> Chain 3: Iteration: 40 / 100 [ 40%]  (Warmup)
#> Chain 3: Iteration: 50 / 100 [ 50%]  (Warmup)
#> Chain 3: Iteration: 51 / 100 [ 51%]  (Sampling)
#> Chain 3: Iteration: 60 / 100 [ 60%]  (Sampling)
#> Chain 3: Iteration: 70 / 100 [ 70%]  (Sampling)
#> Chain 3: Iteration: 80 / 100 [ 80%]  (Sampling)
#> Chain 3: Iteration: 90 / 100 [ 90%]  (Sampling)
#> Chain 3: Iteration: 100 / 100 [100%]  (Sampling)
#> Chain 3: 
#> Chain 3:  Elapsed Time: 0 seconds (Warm-up)
#> Chain 3:                0 seconds (Sampling)
#> Chain 3:                0 seconds (Total)
#> Chain 3: 
#> 
#> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
#> Chain 4: 
#> Chain 4: Gradient evaluation took 3e-06 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.03 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4: 
#> Chain 4: 
#> Chain 4: WARNING: There aren't enough warmup iterations to fit the
#> Chain 4:          three stages of adaptation as currently configured.
#> Chain 4:          Reducing each adaptation stage to 15%/75%/10% of
#> Chain 4:          the given number of warmup iterations:
#> Chain 4:            init_buffer = 7
#> Chain 4:            adapt_window = 38
#> Chain 4:            term_buffer = 5
#> Chain 4: 
#> Chain 4: Iteration:  1 / 100 [  1%]  (Warmup)
#> Chain 4: Iteration: 10 / 100 [ 10%]  (Warmup)
#> Chain 4: Iteration: 20 / 100 [ 20%]  (Warmup)
#> Chain 4: Iteration: 30 / 100 [ 30%]  (Warmup)
#> Chain 4: Iteration: 40 / 100 [ 40%]  (Warmup)
#> Chain 4: Iteration: 50 / 100 [ 50%]  (Warmup)
#> Chain 4: Iteration: 51 / 100 [ 51%]  (Sampling)
#> Chain 4: Iteration: 60 / 100 [ 60%]  (Sampling)
#> Chain 4: Iteration: 70 / 100 [ 70%]  (Sampling)
#> Chain 4: Iteration: 80 / 100 [ 80%]  (Sampling)
#> Chain 4: Iteration: 90 / 100 [ 90%]  (Sampling)
#> Chain 4: Iteration: 100 / 100 [100%]  (Sampling)
#> Chain 4: 
#> Chain 4:  Elapsed Time: 0 seconds (Warm-up)
#> Chain 4:                0 seconds (Sampling)
#> Chain 4:                0 seconds (Total)
#> Chain 4:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#tail-ess

Created on 2021-01-20 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 7 x64 SP 1          
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  Dutch_Belgium.1252          
#>  ctype    Dutch_Belgium.1252          
#>  tz       Europe/Paris                
#>  date     2021-01-20                  
#> 
#> - Packages -------------------------------------------------------------------
#>  ! package      * version     date       lib source        
#>    assertthat     0.2.1       2019-03-21 [1] CRAN (R 4.0.0)
#>    callr          3.5.1       2020-10-13 [1] CRAN (R 4.0.3)
#>    cli            2.2.0       2020-11-20 [1] CRAN (R 4.0.3)
#>    codetools      0.2-16      2018-12-24 [2] CRAN (R 4.0.2)
#>    colorspace     2.0-0       2020-11-11 [1] CRAN (R 4.0.3)
#>    crayon         1.3.4       2017-09-16 [1] CRAN (R 4.0.0)
#>    curl           4.3         2019-12-02 [1] CRAN (R 4.0.0)
#>    desc           1.2.0       2018-05-01 [1] CRAN (R 4.0.0)
#>    devtools       2.3.1       2020-07-21 [1] CRAN (R 4.0.2)
#>    digest         0.6.27      2020-10-24 [1] CRAN (R 4.0.3)
#>    dplyr          1.0.2       2020-08-18 [1] CRAN (R 4.0.2)
#>    ellipsis       0.3.1       2020-05-15 [1] CRAN (R 4.0.2)
#>    evaluate       0.14        2019-05-28 [1] CRAN (R 4.0.0)
#>    fansi          0.4.1       2020-01-08 [1] CRAN (R 4.0.0)
#>    fs             1.5.0       2020-07-31 [1] CRAN (R 4.0.2)
#>    generics       0.1.0       2020-10-31 [1] CRAN (R 4.0.3)
#>    ggplot2        3.3.2       2020-06-19 [1] CRAN (R 4.0.2)
#>    glue           1.4.2       2020-08-27 [1] CRAN (R 4.0.2)
#>    gridExtra      2.3         2017-09-09 [1] CRAN (R 4.0.0)
#>    gtable         0.3.0       2019-03-25 [1] CRAN (R 4.0.0)
#>    highr          0.8         2019-03-20 [1] CRAN (R 4.0.0)
#>    htmltools      0.5.0       2020-06-16 [1] CRAN (R 4.0.2)
#>    inline         0.3.17      2020-12-01 [1] CRAN (R 4.0.3)
#>    jsonlite       1.7.2       2020-12-09 [1] CRAN (R 4.0.3)
#>    knitr          1.30        2020-09-22 [1] CRAN (R 4.0.3)
#>    lifecycle      0.2.0       2020-03-06 [1] CRAN (R 4.0.0)
#>    loo            2.4.1       2020-12-09 [1] CRAN (R 4.0.3)
#>    magrittr       2.0.1       2020-11-17 [1] CRAN (R 4.0.3)
#>    matrixStats    0.56.0      2020-03-13 [1] CRAN (R 4.0.0)
#>    memoise        1.1.0       2017-04-21 [1] CRAN (R 4.0.0)
#>    munsell        0.5.0       2018-06-12 [1] CRAN (R 4.0.0)
#>    pillar         1.4.7       2020-11-20 [1] CRAN (R 4.0.3)
#>    pkgbuild       1.2.0       2020-12-15 [1] CRAN (R 4.0.2)
#>    pkgconfig      2.0.3       2019-09-22 [1] CRAN (R 4.0.0)
#>    pkgload        1.1.0       2020-05-29 [1] CRAN (R 4.0.2)
#>    prettyunits    1.1.1       2020-01-24 [1] CRAN (R 4.0.0)
#>    processx       3.4.5       2020-11-30 [1] CRAN (R 4.0.3)
#>    ps             1.5.0       2020-12-05 [1] CRAN (R 4.0.3)
#>    purrr          0.3.4       2020-04-17 [1] CRAN (R 4.0.0)
#>    R6             2.5.0       2020-10-28 [1] CRAN (R 4.0.3)
#>    Rcpp           1.0.5       2020-07-06 [1] CRAN (R 4.0.2)
#>  D RcppParallel   5.0.2       2020-06-24 [1] CRAN (R 4.0.3)
#>    remotes        2.2.0       2020-07-21 [1] CRAN (R 4.0.2)
#>    rlang          0.4.9       2020-11-26 [1] CRAN (R 4.0.3)
#>    rmarkdown      2.4         2020-09-30 [1] CRAN (R 4.0.3)
#>    rprojroot      2.0.2       2020-11-15 [1] CRAN (R 4.0.3)
#>    rstan        * 2.26.0.9000 2021-01-20 [1] local         
#>    scales         1.1.1       2020-05-11 [1] CRAN (R 4.0.2)
#>    sessioninfo    1.1.1       2018-11-05 [1] CRAN (R 4.0.0)
#>    StanHeaders  * 2.26.0.9000 2021-01-20 [1] local         
#>    stringi        1.5.3       2020-09-09 [1] CRAN (R 4.0.2)
#>    stringr        1.4.0       2019-02-10 [1] CRAN (R 4.0.0)
#>    testthat       3.0.0       2020-10-31 [1] CRAN (R 4.0.3)
#>    tibble         3.0.4       2020-10-12 [1] CRAN (R 4.0.3)
#>    tidyselect     1.1.0       2020-05-11 [1] CRAN (R 4.0.2)
#>    usethis        1.6.1       2020-04-29 [1] CRAN (R 4.0.0)
#>    V8             3.4.0       2020-11-04 [1] CRAN (R 4.0.3)
#>    vctrs          0.3.5       2020-11-17 [1] CRAN (R 4.0.3)
#>    withr          2.4.0       2021-01-16 [1] CRAN (R 4.0.2)
#>    xfun           0.19        2020-10-30 [1] CRAN (R 4.0.3)
#>    yaml           2.2.1       2020-02-01 [1] CRAN (R 4.0.0)
#> 
#> [1] C:/R/Library
#> [2] C:/Program Files/R/R-4.0.2/library
#> 
#>  D -- DLL MD5 mismatch, broken installation.

@hsbadr
Copy link
Member

hsbadr commented Jan 20, 2021

library(rstan)
st <- '
functions{
 real plus(real a){
 return a + 1;
 }
}
'

testcpp <- stanc(model_code = st)

Ok. I'll look into it. It's likely b/c I added a preprocessor. Can you try: testcpp <- stanc(file = "", model_code = st) for now?

@cdriveraus
Copy link

That works and everything compiles and runs, and looks like normal, but the log probability / parameter values are all wrong. Will take me some time to see why.

@hsbadr
Copy link
Member

hsbadr commented Jan 20, 2021

That works and everything compiles and runs, and looks like normal, but the log probability / parameter values are all wrong. Will take me some time to see why.

In the current version I'm testing, it complains about plus in your code. Need to rename it.

@rok-cesnovar
Copy link
Member Author

Yes, plus is a Stan function as well and user defined functions can not shadow Stan function names.

@cdriveraus
Copy link

cdriveraus commented Jan 20, 2021

That was just a cheap mwe, not my actual test problem ;) but sure. I've narrowed down the problem to the gradient calculation of some limited set of functions, but the functions on their own seem ok... will try some more.

Additionally, I posted a (edit) very silly issue and closed here: stan-dev/stanc3#801
but maybe a more informative error could be considered sometime :)

@jeffreypullin
Copy link
Contributor

One further thing that could be done for testing is to use the revdepcheck package from RStudio et. al. to check whether this new version breaks any of the existing CRAN packages with dependencies on {rstan}. Unfortunately I don't think I have the time nor computing power to do it myself at the moment though.

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

@jeffreypullin I did that (in my environment: Linux + Intel compilers + R-devel) and I'm using this version in production with almost all of its dependencies. I think we've two tasks:

  1. Maintainers review the code to make sure they're happy with the changes for future development.
  2. Users and/or devs test it in their use cases to catch any hidden errors (e.g., the stanc file issue that I've fixed).

The good thing is that this is now following Stan development and the package deployment has been automated. This can ensure that rstan development is coupled with Stan.

@jeffreypullin
Copy link
Contributor

Oh wow, sorry @hsbadr I didn't realize you'd already done that! I completely agree with 1 and 2.

@rok-cesnovar
Copy link
Member Author

The problem is the rstan tests arent really that rich. For example this case with the model code should have definitely been caught by at least one unit test. Expanding unit tests is definitely something we need to do in order to simplify the release cycle.

@cdriveraus
Copy link

Ok. I spent the morning diagnosing the 'incorrect gradient under certain conditions' thing, and it magically fixed itself :/ No idea how / why, maybe some remnant left in memory? Anyway, tests are passing, seems fine, speed seems nicely bumped up!

One thing: in rstan 2.21, I got this:

Variable "JAX" does not exist.
 error in 'model_ctsmgen' at line 1055, column 46
  -------------------------------------------------
  1053:   
  1054:       asymDIFFUSION[ derrind, derrind ] = 
  1055:         to_matrix( (add_diag( -sqkron_prod(JAX[ derrind, derrind ], JAX[ derrind, derrind ]),

but this parses in rstan 2.26 and then gives a compile error.

@rok-cesnovar
Copy link
Member Author

Can you paste the entire model or link it. Thanks

@cdriveraus
Copy link

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

@cdriveraus @rok-cesnovar I think it's more of stanc --allow-undefined option. The variable JAX seems to be undefined and in one version it's allowed in stanc and failed in compilation and in the other one stanc rejected` it. You may need to provide the headers that define it.

@cdriveraus
Copy link

Not sure I follow. It was just a miscapitalisation (should have been JAx) .

@rok-cesnovar
Copy link
Member Author

Hm, I get

Semantic error in 'string', line 917, column 43 to column 46: Identifier 'JAX' not in scope.

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

Hm, I get

Semantic error in 'string', line 917, column 43 to column 46: Identifier 'JAX' not in scope.

I think this is likely a valid error and may depend on the compiler version and flags. Does it run with the old version of rsran? If not, then, it should be in a separate issue, not related to this one.

@rok-cesnovar
Copy link
Member Author

Yes, this error I get is correct and valid.

@cdriveraus
Copy link

yes that is a valid error. However, when I use stanc("", model_code=x) , it doesn't give the error, which is the problem.

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

yes that is a valid error. However, when I use stanc("", model_code=x) , it doesn't give the error, which is the problem.

It just allows undefined variables, not really an issue with rstan as it's a valid error and stanc3 didn't complain. So, @rok-cesnovar, is there an option in stanc3 to check undefined variables and how to pass it to the JS?

@rok-cesnovar
Copy link
Member Author

Hm, I am not sure why would it allow undefined variables? If I place that model here: https://rok-cesnovar.github.io/stanc3js-demo/index.html I get the error. And this link uses the exact same javascript file. So the issue might be rstan does not catch the error? Will check.

@cdriveraus
Copy link

if I use stanc(file=x) instead of the model_code approach, it gives the error, so I don't think this is intended (or at least, consistent!) behaviour.

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

What's the status (...$status) of the generated code?

@hsbadr
Copy link
Member

hsbadr commented Jan 21, 2021

@cdriveraus @rok-cesnovar It does work as expected. Have you installed the latest rstan 2.26 binaries?

> library(rstan)
Loading required package: StanHeaders
rstan (Version 2.26.0.9000, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
> cppcode <- stanc(file = "ctsm.stan")
Info: Found int division at 'string', line 57, column 10 to column 17:
  (d * d - d) / 2
Values will be rounded towards zero. If rounding is not desired you can write
the division as
  (d * d - d) / 2.0
0

Semantic error in 'string', line 867, column 43 to column 46:

Identifier 'JAX' not in scope.
> cppcode$status
[1] FALSE

@cdriveraus
Copy link

Maybe it's confusing because 'giving an error' is actually the desired behaviour. yes, stanc(file=x) works correctly. stanc(file="",model_code=x) does not return an error, which seems incorrect.

@bgoodri
Copy link
Contributor

bgoodri commented Mar 4, 2021 via email

@bbbales2
Copy link
Member

bbbales2 commented Mar 4, 2021

stan::math::LDLT_factor<double>

The template argument to the new LDLT_factor is the type of matrix it is factorizing. So I think there you probably want this:

stan::math::LDLT_factor<Eigen::Matrix<param_t, Eigen::Dynamic, Eigen::Dynamic>>

@hsbadr
Copy link
Member

hsbadr commented Mar 4, 2021

Do you know what I need to tell OpenMx to do to fix this?

Yes. I'll work on a PR to OpenMx. Is there any other dependencies require patching?

For the following rstan release, we may need rstantools and some packages that don't inherit the flags from rstan plugin to conditionally add -DUSE_STANC3 to CPPFLAGS, using something like if (utils::packageVersion("rstan") >= 2.26).

The template argument to the new LDLT_factor is the type of matrix it is factorizing. So I think there you probably want this:

stan::math::LDLT_factor<Eigen::Matrix<param_t, Eigen::Dynamic, Eigen::Dynamic>>

Thanks @bbbales2! I noticed that in the new tests (stan-dev/math#2266), and will try:

auto ldlt_Sigma = stan::math::make_ldlt_factor(Sigma);

@hsbadr
Copy link
Member

hsbadr commented Mar 5, 2021

@bgoodri OpenMx/OpenMx#308 fixes OpenMx.

@cdriveraus
Copy link

cdriveraus commented Mar 15, 2021

getting compile error when trying to use multiple cores, I have
CXX14FLAGS += -DSTAN_THREADS
in my makevars, is there something else needed?

> rstan_options(threads_per_chain = 10)
> sm=stan_model(file='2plagereduce.stan')
make cmd is
  make -f "C:/PROGRA~1/R/R-40~1.4/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-40~1.4/share/make/winshlib.mk" -f "C:/Users/Driver/Documents/.R/Makevars.win" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file42c440705ed.dll" WIN=64 TCLBIN=64 OBJECTS="file42c440705ed.o"

make would use
"C:/rtools40/mingw64/bin/"g++  -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.4/include" -DNDEBUG   -I"C:/Users/Driver/Documents/R/win-library/4.0/Rcpp/include/"  -I"C:/Users/Driver/Documents/R/win-library/4.0/RcppEigen/include/"  -I"C:/Users/Driver/Documents/R/win-library/4.0/RcppEigen/include/unsupported"  -I"C:/Users/Driver/Documents/R/win-library/4.0/BH/include" -I"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/include/src/"  -I"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/include/"  -I"C:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/include/"  -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/Driver/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -DBOOST_NO_AUTO_PTR  -include "C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/fun/Eigen.hpp"  -std=c++1y  -Wno-ignored-attributes       -O1 -mtune=native   -DSTAN_THREADS -c file42c440705ed.cpp -o file42c440705ed.o
if test "zfile42c440705ed.o" != "z"; then \
  if test -e "file42c440705ed-win.def"; then \
    echo "C:/rtools40/mingw64/bin/"g++  -shared -s -static-libgcc -o file42c440705ed.dll file42c440705ed-win.def file42c440705ed.o   "C:/Users/Driver/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -LC:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64 -ltbb -ltbbmalloc  -L"C:/PROGRA~1/R/R-40~1.4/bin/x64" -lR ; \
    "C:/rtools40/mingw64/bin/"g++  -shared -s -static-libgcc -o file42c440705ed.dll file42c440705ed-win.def file42c440705ed.o   "C:/Users/Driver/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -LC:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64 -ltbb -ltbbmalloc  -L"C:/PROGRA~1/R/R-40~1.4/bin/x64" -lR ; \
  else \
    echo EXPORTS > tmp.def; \
    "C:/rtools40/mingw64/bin/"nm file42c440705ed.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g'  >> tmp.def; \
    echo "C:/rtools40/mingw64/bin/"g++  -shared -s -static-libgcc -o file42c440705ed.dll tmp.def file42c440705ed.o   "C:/Users/Driver/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -LC:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64 -ltbb -ltbbmalloc  -L"C:/PROGRA~1/R/R-40~1.4/bin/x64" -lR ; \
    "C:/rtools40/mingw64/bin/"g++  -shared -s -static-libgcc -o file42c440705ed.dll tmp.def file42c440705ed.o   "C:/Users/Driver/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -LC:/Users/Driver/Documents/R/win-library/4.0/RcppParallel/lib/x64 -ltbb -ltbbmalloc  -L"C:/PROGRA~1/R/R-40~1.4/bin/x64" -lR ; \
    rm -f tmp.def; \
  fi \
fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
                   from C:/Users/Driver/Documents/R/win-library/4.0/rstan/include/rstan/rstaninc.hpp:4,                 from file42c440705ed.cpp:12:C:/Users/Driver/Documents/R/win-library/4.0/StanHeaders/include/tbb/tbb_stddef.h:333:5: note: declared private here     no_copy( const no_copy& );     ^~~~~~~make: *** [C:/PROGRA~1/R/R-40~1.4/etc/x64/Makeconf:229: file42c440705ed.o] Error 1
Error in sink(type = "output") : invalid connection

2plagereduce.zip

@rok-cesnovar
Copy link
Member Author

AFAIK rstan uses STAN_THREADS by default: https://github.com/stan-dev/rstan/pull/887/files#diff-cf22d8a9d8c4b1f76afa5d1853516d2ae2d7cc4e01ac7e190fb845539848fec1L56

So maybe try removing CXX14FLAGS += -DSTAN_THREADS, though its unlikely a duplicated definition would cause problems.

@cdriveraus
Copy link

Yeah should have mentioned, I only added that because of the error in the first place.

@hsbadr
Copy link
Member

hsbadr commented Mar 15, 2021

@cdriveraus Which version of StanHeaders do you use? 2.26.1.9000 or 2.26.1? If the latter, it seems that you've conflicting TBB headers because we shouldn't ship those headers in StanHeaders at all (should link to RcppParallel instead). So, try to SteanHeaders from #887 or remove tbb directory from StanHeaders/include.

BTW. Checking the error you posted here that requires -DUSE_STANC3 flag, it looks like you used a code generated by an earlier development version of rstan since we already define USE_STANC3 by default in the code generated by the latest version or rstan::stanc. i.e., you may not need to edit you Makevars if you generated the code using the current version.

@cdriveraus
Copy link

Ok. I'm just using whatever is available as a binary from the stan repo -- you're right it's 2.26.1. let me know if that's too out of date now and better to not post random problems / queries in this thread anymore then!

@cdriveraus
Copy link

cdriveraus commented Mar 25, 2021

With 2.26.1 the following code crashes R in windows, while with 2.21 an exception is output. Still not sure whether to keep adding stuff to this thread based on 2.26.1...

 "  Exception: Exception: []: accessing element out of range. index 37 out of range; expecting index to be between 1 and 36; index position = 1rawcor  (in 'model11803abf28_b8e4ecfffd5c676b393a9c9ac47e9b45' at line 12)"
[3] "  (in 'model11803abf28_b8e4ecfffd5c676b393a9c9ac47e9b45' at line 39)"   

require(rstan)

smt <- '
functions{
   matrix constraincorsqrt(vector rawcor, int d){ //converts from unconstrained lower tri matrix to cor
    matrix[d,d] o;
    vector[d] s;
    real sumrawcor = sqrt(1+sum(fabs(rawcor)));
    int counter = 0;
    
    for(i in 1:d){ //constrain and set upper tri to lower
      for(j in min(i+1,d):d){
        counter += 1;
        o[j,i] =  inv_logit(rawcor[counter]/sumrawcor)*2-1;  // can change cor prior here
        o[i,j] = o[j,i];
      }
    }
    for(i in 1:d){
      o[i,i]=1; 
      s[i] = inv_sqrt(sum(square(o[i,]))+1e-10);
    }
    return diag_matrix(s) * o;
  }
}
data{
  int d;
  int n;
  vector[d] dat[n];
  real corpriorscale;
}
parameters{
  vector[(d * d - d) / 2] rawcor;
  vector[d] logsdvec;
  vector[d] mu;
}
transformed parameters{
  matrix[d,d] mcor;
  matrix[d, d] mcov;
  matrix[d, d] mcovchol;

  mcor = tcrossprod(constraincorsqrt(rawcor,d));
  mcov = quad_form_diag(mcor, exp(logsdvec) +1e-8);
  mcovchol = cholesky_decompose(mcov); 
}
model{
  rawcor ~ normal(0,corpriorscale);
  logsdvec ~ normal(0,10);
  mu ~ normal(0,10);
  dat ~ multi_normal_cholesky(mu,mcovchol);
}
'

sm <- stan_model(model_code = smt)


d=9
n=30
mcov <- diag(1,d)
mcov[lower.tri(mcov)][seq(1,(d^2-d)/2,d)] <- .8
mcov[upper.tri(mcov)] <- t(mcov)[upper.tri(mcov)]
mcov <- cov2cor(mcov %*% t(mcov))
mcovchol <- t(chol(mcov))
mcor=cov2cor(mcov)
dat <- matrix(rnorm(d*n,0,1),n,d)
dat <- t(mcovchol %*% t(dat))
dat <- scale(dat)
round(cor(dat),3)
round(mcor,3)


sdat <- list(n=n,d=d, dat=dat,corpriorscale=5)
# sf <- ctsem:::stanWplot(sm,sdat,chains=4,cores=4,iter=2000)
sf <- sampling(sm,sdat,chains=1,cores=1,iter=2000)

@rok-cesnovar
Copy link
Member Author

This is an issue that was fixed in stanc3 and this will only be fixed for the 2.27 version. The issue was that the stanc3 did not do some of the range checks: stan-dev/stanc3#849

@hsbadr
Copy link
Member

hsbadr commented Mar 25, 2021

With 2.26.1 the following code crashes R in windows, while with 2.21 an exception is output.

This is an issue that was fixed in stanc3 and this will only be fixed for the 2.27 version. The issue was that the stanc3 did not do some of the range checks: stan-dev/stanc3#849

Based on @rok-cesnovar's comment, I suggest using the nightly version of stanc3 by removing the local JS file:

file.remove(system.file("stanc.js", package = "rstan"))

@helske
Copy link

helske commented Mar 26, 2021

I downloaded new rstan and StanHeaders from https://mc-stan.org/r-packages/, and tried to rebuild walker, which relies on Stan, but I get a very long list of errors, ending with

   C:/MyTemp/Rlibs/RcppEigen/include/Eigen/src/Core/CwiseBinaryOp.h:177:18:   required from 'Derived& Eigen::MatrixBase<Derived>::operator+=(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::Product<Eigen::Product<Eigen::Matrix<double, -1, 1>, Eigen::Matrix<double, 1, 1, 0, 1, 1>, 0>, Eigen::Transpose<const Eigen::Matrix<double, -1, 1> >, 0>; Derived = Eigen::CwiseUnaryView<Eigen::MatrixBase<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >::adj_Op, Eigen::Matrix<stan::math::var_value<double>, -1, -1> >]'
   C:/MyTemp/Rlibs/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:63:13:   required from 'void stan::math::internal::quad_form_vari<Ta, Ra, Ca, Tb, Rb, Cb>::chainA(Eigen::Matrix<stan::math::var_value<double>, R1, C1>&, const Eigen::Matrix<double, Rb, Cb>&, const Eigen::Matrix<double, Cb, Cb>&) [with Ta = stan::math::var_value<double>; int Ra = -1; int Ca = -1; Tb = double; int Rb = -1; int Cb = 1]'
   C:/MyTemp/Rlibs/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:77:5:   required from 'void stan::math::internal::quad_form_vari<Ta, Ra, Ca, Tb, Rb, Cb>::chainAB(Eigen::Matrix<T, R, C>&, Eigen::Matrix<Tb, Rb, Cb>&, const Eigen::Matrix<double, R1, C1>&, const Eigen::Matrix<double, Rb, Cb>&, const Eigen::Matrix<double, Cb, Cb>&) [with Ta = stan::math::var_value<double>; int Ra = -1; int Ca = -1; Tb = double; int Rb = -1; int Cb = 1]'
   C:/MyTemp/Rlibs/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:91:5:   required from 'void stan::math::internal::quad_form_vari<Ta, Ra, Ca, Tb, Rb, Cb>::chain() [with Ta = stan::math::var_value<double>; int Ra = -1; int Ca = -1; Tb = double; int Rb = -1; int Cb = 1]'
   C:/MyTemp/Rlibs/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:88:16:   required from here
   C:/MyTemp/Rlibs/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__vector(2) double'} [-Wignored-attributes]
   make: *** [C:/Devel/R/etc/x64/Makeconf:227: stanExports_rw1_model.o] Error 1
   ERROR: compilation failed for package 'walker'

Based on the comments above I then added the -DUSE_STANC3 to the Makevars, but this only adds more errors, now related to TBB.

Makevars.win:

STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders")

PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG

CXX_STD = CXX14

PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

all: $(SHLIB)

@tristansnowsill
Copy link

Thanks for all the hard work.

I'm trying to compile the experimental version (following instructions at #887) on Raspberry Pi 400 (Debian, armv7l architecture). StanHeaders compiled fine, but rstan is failing with this error:

/home/pi/R/armv7l-unknown-linux-gnueabihf-library/4.0/StanHeaders/include/stan/math/rev/functor/reduce_sum.hpp:259:27: error: `isolate' is not a member of `tbb::this_task_arena'
     tbb::this_task_arena::isolate([&] {
                           ^~~~~~~

Can you advise?

@hsbadr
Copy link
Member

hsbadr commented Mar 29, 2021

Thanks for all the hard work.

I'm trying to compile the experimental version (following instructions at #887) on Raspberry Pi 400 (Debian, armv7l architecture). StanHeaders compiled fine, but rstan is failing with this error:

/home/pi/R/armv7l-unknown-linux-gnueabihf-library/4.0/StanHeaders/include/stan/math/rev/functor/reduce_sum.hpp:259:27: error: `isolate' is not a member of `tbb::this_task_arena'
     tbb::this_task_arena::isolate([&] {
                           ^~~~~~~

Can you advise?

You need to install the development version of RcppParallel from GitHub.

@tristansnowsill
Copy link

tristansnowsill commented Mar 29, 2021

Thanks for all the hard work.
I'm trying to compile the experimental version (following instructions at #887) on Raspberry Pi 400 (Debian, armv7l architecture). StanHeaders compiled fine, but rstan is failing with this error:

/home/pi/R/armv7l-unknown-linux-gnueabihf-library/4.0/StanHeaders/include/stan/math/rev/functor/reduce_sum.hpp:259:27: error: `isolate' is not a member of `tbb::this_task_arena'
     tbb::this_task_arena::isolate([&] {
                           ^~~~~~~

Can you advise?

You need to install the development version of RcppParallel from GitHub.

Thanks. It has now successfully compiled but unfortunately I cannot use it to build a model because of another error...

I tried to run example(stan_model, package = "rstan", run.dontrun = TRUE) and got the following:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  file32be35e6c31f.cpp:63:20: error: `stan::model::cons_list' has not been declared using stan::model::cons_list;
                    ^~~~~~~~~file32be35e6c31f.cpp:70:20: error: `stan::model::nil_index_list' has not been declared using stan::model::nil_index_list;
                    ^~~~~~~~~~~~~~make: *** [/usr/local/lib/R/etc/Makeconf:179: file32be35e6c31f.o] Error 1

When I tried to build one of my own models I got a different error, but I expect it is less helpful to see those at this stage.

Thank you for your support it is really appreciated!

@dmi3kno
Copy link

dmi3kno commented Apr 16, 2021

I am trying to use the new algebra solvers functionality, in particular algebra_solver_newton. I am getting the following error at compile time:

Error in dyn.load(libLFile) : 
  unable to load shared object '/tmp/Rtmpx0UAse/file15885181a3f8d.so':
  /tmp/Rtmpx0UAse/file15885181a3f8d.so: undefined symbol: KINSetJacFn
Error in sink(type = "output") : invalid connection

Is my SUNDIALS header getting properly linked? I can make a small reprex to make into the unit test in the future, if necessary.

@rok-cesnovar
Copy link
Member Author

Thanks for the report @dmi3kno.

@hsbadr algebra_solver_newton requires libsundials_kinsol.a to be built (that was added in Stan Math since the last rstan). Any chance this wasnt added for rstan 2.26?

@hsbadr
Copy link
Member

hsbadr commented Apr 16, 2021

Thank you both @rok-cesnovar & @dmi3kno!

algebra_solver_newton requires libsundials_kinsol.a to be built (that was added in Stan Math since the last rstan). Any chance this wasnt added for rstan 2.26?

Yes, SUNDIALS_KINSOL is commented out in the Makevars of StanHeaders. I'll look into it.

@hsbadr
Copy link
Member

hsbadr commented Apr 17, 2021

algebra_solver_newton requires libsundials_kinsol.a to be built (that was added in Stan Math since the last rstan). Any chance this wasnt added for rstan 2.26?

2b33ea7 should do it. It has been cherry-picked into #912 too. Please update the packages so that @dmi3kno could test it.

@dmi3kno
Copy link

dmi3kno commented Apr 17, 2021

Is there a way for me to try it before the PR is merged? I tried installing dev versions off of your repo @hsbadr yesterday and could not get it to work. There was some update in RcppParallel in the meantime? What's the right combination of StanHeaders, RcppEigen RcppParallel and rstan to try the version with SUNDIALS optimizers?

@rok-cesnovar
Copy link
Member Author

The easiest way to try it out will be once I rebuild the packages. Will do in a few hours.

@rok-cesnovar
Copy link
Member Author

Updated the packages. Please run

remove.packages(c("rstan","StanHeaders"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

@cdriveraus
Copy link

cdriveraus commented Jun 22, 2021

Trying to build ctsem with just Stanheaders 2.26.2 and rstan 2.21 I get a lot of errors:

==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source ctsem

* installing to library 'C:/Users/Driver/Documents/R/win-library/4.2'
* installing *source* package 'ctsem' ...
** using staged installation
** libs
"C:/PROGRA~1/R/R-devel/bin/x64/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/ctsmgen.stan
"C:/PROGRA~1/R/R-devel/bin/x64/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/cov.stan
"C:/PROGRA~1/R/R-devel/bin/x64/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/ctsm.stan


"C:/rtools40/mingw64/bin/"g++  -std=gnu++14 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG -I"../inst/include" -I"C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 -DUSE_STANC3  -I'C:/Users/Driver/Documents/R/win-library/4.2/BH/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/Rcpp/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/rstan/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include' -Wno-ignored-attributes    -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include" -D_REENTRANT -DSTAN_THREADS     -O1 -mtune=native   -c init.cpp -o init.o
DIAGNOSTIC(S) FROM PARSER:
Info: integer division implicitly rounds to integer. Found int division: d * d - d / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.
Info: integer division implicitly rounds to integer. Found int division: d * d - d / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.

Wrote C++ file "stan_files/cov.cc"
DIAGNOSTIC(S) FROM PARSER:
Info: integer division implicitly rounds to integer. Found int division: d * d - d / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.

DIAGNOSTIC(S) FROM PARSER:
Info: integer division implicitly rounds to integer. Found int division: d * d - d / 2
 Positive values rounded down, negative values rounded up or down in platform-dependent way.



Wrote C++ file "stan_files/ctsmgen.cc"
Wrote C++ file "stan_files/ctsm.cc"
"C:/rtools40/mingw64/bin/"g++  -std=gnu++14 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG -I"../inst/include" -I"C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 -DUSE_STANC3  -I'C:/Users/Driver/Documents/R/win-library/4.2/BH/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/Rcpp/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/rstan/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include' -Wno-ignored-attributes    -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include" -D_REENTRANT -DSTAN_THREADS     -O1 -mtune=native   -c stan_files/cov.cc -o stan_files/cov.o
"C:/rtools40/mingw64/bin/"g++  -std=gnu++14 -I"C:/PROGRA~1/R/R-devel/include" -DNDEBUG -I"../inst/include" -I"C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 -DUSE_STANC3  -I'C:/Users/Driver/Documents/R/win-library/4.2/BH/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/Rcpp/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/rstan/include' -I'C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include' -Wno-ignored-attributes    -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/Driver/Documents/R/win-library/4.2/RcppParallel/include" -D_REENTRANT -DSTAN_THREADS     -O1 -mtune=native   -c stan_files/ctsm.cc -o stan_files/ctsm.o


***** deleted stuff *****

In file included from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/var.hpp:14,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/meta/is_var.hpp:5,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/meta.hpp:7,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/accumulate_adjoints.hpp:5,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core.hpp:4,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev.hpp:8,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src/stan/model/test_gradients.hpp:7,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:8,
                 from C:/Users/Driver/Documents/R/win-library/4.2/rstan/include/rstan/stan_fit.hpp:35,
                 from C:/Users/Driver/Documents/R/win-library/4.2/rstan/include/rstan/rstaninc.hpp:4,
                 from stan_files/ctsm.hpp:18,
                 from stan_files/ctsm.cc:3:
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp: At global scope:
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::internal::unblocked_cholesky_lambda(T1&, T2&, T3&) [with T1 = stan::math::arena_matrix<Eigen::Matrix<double, -1, -1> >; T2 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T3 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >]::<lambda()>]', declared using local type 'stan::math::internal::unblocked_cholesky_lambda(T1&, T2&, T3&) [with T1 = stan::math::arena_matrix<Eigen::Matrix<double, -1, -1> >; T2 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T3 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >]::<lambda()>', is used but never defined [-fpermissive]
 inline void reverse_pass_callback(F&& functor) {
             ^~~~~~~~~~~~~~~~~~~~~
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::internal::cholesky_lambda(T1&, T2&, T3&) [with T1 = stan::math::arena_matrix<Eigen::Matrix<double, -1, -1> >; T2 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T3 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >]::<lambda()>]', declared using local type 'stan::math::internal::cholesky_lambda(T1&, T2&, T3&) [with T1 = stan::math::arena_matrix<Eigen::Matrix<double, -1, -1> >; T2 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T3 = stan::math::arena_matrix<Eigen::Matrix<stan::math::var_value<double>, -1, -1> >]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<stan::math::var_value<double>, 1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<stan::math::var_value<double>, 1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<double, 1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<double, 1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, 1, -1, false>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, 1, -1, false>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Matrix<stan::math::var_value<double>, 1, -1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Matrix<stan::math::var_value<double>, 1, -1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = double; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::subtract(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::subtract(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = stan::math::var_value<double>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = stan::math::var_value<double>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_not_matrix_t<T1>* <anonymous> = 0; stan::require_matrix_t<T2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::subtract(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::subtract(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::subtract(const VarMat&, const Arith&) [with Arith = Eigen::Matrix<double, -1, -1>; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::subtract(const VarMat&, const Arith&) [with Arith = Eigen::Matrix<double, -1, -1>; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Block<Eigen::Matrix<stan::math::var_value<double>, -1, -1>, -1, 1, true>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::add(const VarMat1&, const VarMat2&) [with VarMat1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; VarMat2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_rev_matrix_t<VarMat1, VarMat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<double, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<double, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::subtract(const Arith&, const VarMat&) [with Arith = Eigen::Matrix<double, -1, 1>; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::subtract(const Arith&, const VarMat&) [with Arith = Eigen::Matrix<double, -1, 1>; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Transpose<const Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::CwiseUnaryOp<Eigen::internal::scalar_opposite_op<stan::math::var_value<double> >, const Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::CwiseUnaryOp<Eigen::internal::scalar_opposite_op<stan::math::var_value<double> >, const Eigen::Matrix<stan::math::var_value<double>, -1, -1> >; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::multiply(const T1&, const T2&) [with T1 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; T2 = Eigen::Matrix<stan::math::var_value<double>, -1, -1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_st_var<T1, T2>* <anonymous> = 0; stan::require_return_type_t<stan::is_var, T1, T2>* <anonymous> = 0; stan::require_not_row_and_col_vector_t<T1, T2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::elt_multiply(const Mat1&, const Mat2&) [with Mat1 = Eigen::Matrix<double, -1, 1>; Mat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_rev_matrix_t<Mat1, Mat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::elt_multiply(const Mat1&, const Mat2&) [with Mat1 = Eigen::Matrix<double, -1, 1>; Mat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_rev_matrix_t<Mat1, Mat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::subtract(const Arith&, const VarMat&) [with Arith = int; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::subtract(const Arith&, const VarMat&) [with Arith = int; VarMat = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_st_arithmetic<Arith>* <anonymous> = 0; stan::require_rev_matrix_t<VarMat>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/rev/core/reverse_pass_callback.hpp:38:13: error: 'void stan::math::reverse_pass_callback(F&&) [with F = stan::math::elt_multiply(const Mat1&, const Mat2&) [with Mat1 = Eigen::MatrixWrapper<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<int, double>, const Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<int>, const Eigen::Array<int, -1, 1> >, const Eigen::ArrayWrapper<const Eigen::Matrix<double, -1, 1> > > >; Mat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_rev_matrix_t<Mat1, Mat2>* <anonymous> = 0]::<lambda()>]', declared using local type 'stan::math::elt_multiply(const Mat1&, const Mat2&) [with Mat1 = Eigen::MatrixWrapper<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<int, double>, const Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<int>, const Eigen::Array<int, -1, 1> >, const Eigen::ArrayWrapper<const Eigen::Matrix<double, -1, 1> > > >; Mat2 = Eigen::Matrix<stan::math::var_value<double>, -1, 1>; stan::require_all_matrix_t<EigMat1, EigMat2>* <anonymous> = 0; stan::require_any_rev_matrix_t<Mat1, Mat2>* <anonymous> = 0]::<lambda()>', is used but never defined [-fpermissive]
In file included from C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include/Eigen/src/Core/MatrixBase.h:125,
                 from C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include/Eigen/Core:441,
                 from C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include/Eigen/Dense:1,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
                 from C:/Users/Driver/Documents/R/win-library/4.2/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:1,
                 from C:/Users/Driver/Documents/R/win-library/4.2/rstan/include/rstan/rstaninc.hpp:3,
                 from stan_files/ctsm.hpp:18,
                 from stan_files/ctsm.cc:3:
C:/Users/Driver/Documents/R/win-library/4.2/RcppEigen/include/Eigen/src/plugins/CommonCwiseUnaryOps.h:121:1: error: 'const Eigen::CwiseUnaryOp<CustomUnaryOp, const Derived> Eigen::MatrixBase<Derived>::unaryExpr(const CustomUnaryOp&) const [with CustomUnaryOp = stan::math::apply_scalar_unary<F, T, typename std::enable_if<stan::is_eigen<typename std::decay<_Arg>::type>::value, void>::type>::apply(const T&) [with F = stan::math::log_fun; T = Eigen::Matrix<stan::math::var_value<double>, -1, 1>]::<lambda(stan::math::apply_scalar_unary<stan::math::log_fun, Eigen::Matrix<stan::math::var_value<double>, -1, 1>, void>::scalar_t)>; Derived = Eigen::Matrix<stan::math::var_value<double>, -1, 1>]', declared using local type 'const stan::math::apply_scalar_unary<F, T, typename std::enable_if<stan::is_eigen<typename std::decay<_Arg>::type>::value, void>::type>::apply(const T&) [with F = stan::math::log_fun; T = Eigen::Matrix<stan::math::var_value<double>, -1, 1>]::<lambda(stan::math::apply_scalar_unary<stan::math::log_fun, Eigen::Matrix<stan::math::var_value<double>, -1, 1>, void>::scalar_t)>', is used but never defined [-fpermissive]
 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
 ^~~~~~~~~
rm stan_files/ctsmgen.cc stan_files/ctsm.cc stan_files/cov.cc
make: *** [C:/PROGRA~1/R/R-devel/etc/x64/Makeconf:243: stan_files/ctsm.o] Error 1
ERROR: compilation failed for package 'ctsem'
* removing 'C:/Users/Driver/Documents/R/win-library/4.2/ctsem'
* restoring previous 'C:/Users/Driver/Documents/R/win-library/4.2/ctsem'

Exited with status 1.

@hsbadr
Copy link
Member

hsbadr commented Jun 22, 2021

@cdriveraus Just for completeness :) You need to define USE_STANC3 only for the new version of rstan. You may replace -DUSE_STANC3 in PKG_CPPFLAGS with something like:

STANC_FLAGS = "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "cat(ifelse(utils::packageVersion('rstan') >= 2.26, '-DUSE_STANC3', ''))"
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 $(STANC_FLAGS) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests