Can't I put literal of vector to function argument?

Hello everyone.
Please let me ask a question again…

At previous topic I posted, I was taught that I must use when I declare vectors like vector[2] x = [1.0, 2.0]'

And, the following code was successfully compiled:

(Omission)
transformed data{
  vector[1] y_guess = [1.0]';
  real x_r[0];
  int x_i[0];
}

parameters{
  real mu;
  real beta;
}

transformed parameters{
  vector[2] theta = [mu, beta]';
  real alpha = algebra_solver(algebra_system, y_guess, theta, x_r, x_i)[1];
}
(Omission)

However, as theta and y_guess are temporary variables, I tried to rewrite this:

(Omission)
transformed data{
  real x_r[0];
  int x_i[0];
}

parameters{
  real mu;
  real beta;
}

transformed parameters{
  real alpha = algebra_solver(algebra_system, [1.0]', [mu, beta]`, x_r, x_i)[1];
}
(Omission)

And then unfortunately, I got this error message:

Compilation ERROR, function(s)/method(s) not created!

I searched this problem.
According to it, this error seems to be occurred by around Rtools, c++, or gcc.
However, Unlike them who are suffered from same error, when I use temporary variables, compilation has succeeded.

I would not like to use temporary variables for readability.
I appreciate anyone’s help.

Thank you.

Mind including the full Stan program and the full error message? It’s really hard to tell where the error is when the rest of the message is cut off (it should tell you a line number).

Unfortunately, passing things like `[mu, beta]`` tends not to work with the version of rstan on CRAN.

@syclik, @bgoodri
Thank you for your prompt reply.

(to @syclik)
I’m not good at English: does “mind” mean like “dislike” in this situation?
If it is, answer is no.
I wanted to clear where problem is.

(to @bgoodri)
Seriously…?
Well, as when using temp, compilation has succeeded, I will endure it.

Thank you!

What you wrote originally should work for Stan versions >= 2.18.0.

1 Like

Sorry for not being clearer. If I were to rewrite it, it would be “Would you mind including the full Stan program and the full error message?” – it wasn’t a dislike; it was meant to be a request.

I’d trust @bgoodri’s advice on rstan over mine.

This is not going to work because it needs to be [mu, beta]' with a regular apostrophe, not a backwards one. This should work with current releases.

You then also have to be careful that you don’t have that ' mistaken for a close-quote. That’s one reason we recommend having Stan programs in separate files, not embedded in R code as strings (the other is easily accessible line numbers and format-sensitive file editing).