Function algebra_solver_newton not found

Hi,

I’d like to use the Newton method of root finding, but I’m getting the message algebra_solver_newton not found. I was able to use the Powell method with algebra_solver(), so not sure why the Newton method is not recognized.

I’m using R 4.1.1, STAN 2.21.0 on Windows.

Thanks in advance!

1 Like

I don’t think algebra_solver_newton is available in versions before 2.24.0

2 Likes

Edit: posted a link to outdated instructions; here are better ones.

Note that you can get more recent versions of Rstan (which aren’t yet available on CRAN for annoying reasons) as follows:

# Uncomment the next line if you have previously installed rstan
# 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")))
2 Likes

Thanks both, I’ removed and reinstalled the packages according to @jscolar. Now when I check the exact same stan file that compiled before, I get the error:

Error in stanc(filename, allow_undefined = TRUE) : 0

Syntax error in ‘string’, line 63, column 35 to column 36, parsing error:

Expected end of file after end of generated quantities block.

Yes there’s a blank line after the generated quantities block.

Can you post your Stan code?

In your discourse post, let the last line before your code contain exactly “```stan” (without the quotation marks).

This can occur when RStan caches an incorrect model. I’ve found that restarting R allows the model to oarse and compile correctly when this happens

Alrighty thanks everyone. My immediate workaround was to use cmdstanr instead as that loads a more recent version of stan, and I was able to use algebra_solver_newton().
I’ll try installing rstan from mc-stan.org at some point and restarting RStudio.

3 Likes