Old code does not run anymore with rstan 1.1.0

223 views
Skip to first unread message

Lucas Leemann

unread,
Dec 26, 2012, 12:28:30 PM12/26/12
to stan-...@googlegroups.com
Hi all,

I had some code which I used two months ago and it ran without any problems. Now, after downloading rstan 1.1.0 I get error messages and they are not clear (e.g. no matches for function name="inv_logit").

Maybe somebody could take a look at the code and let me know which changes cause the issues so that I can change the code. I am attaching the code as well as a file which generates some fake data.

Thanks in advance,
Lucas

p.s. I use R 2.15.2 and rstan is version 1.1.0
code.rtf
make data.rtf

Ben Goodrich

unread,
Dec 26, 2012, 1:55:33 PM12/26/12
to stan-...@googlegroups.com
Can you attach those two files as .txt? The colorizing of the .rtf files messes everything up when I download them.

Thanks,
Ben

Lucas Leemann

unread,
Dec 26, 2012, 2:57:17 PM12/26/12
to stan-...@googlegroups.com
Hi Ben,

Sorry for the .rtf files. Here are the two files in txt format

Best,
Lucas


code.txt
make data.txt

Lucas Leemann

unread,
Dec 27, 2012, 3:29:29 AM12/27/12
to stan-...@googlegroups.com
Sorry, here are the two txt files.

Best, Lucas
code.txt
make data.txt

Ben Goodrich

unread,
Dec 27, 2012, 12:42:28 PM12/27/12
to stan-...@googlegroups.com
On Thursday, December 27, 2012 3:29:29 AM UTC-5, Lucas Leemann wrote:
Sorry, here are the two txt files.
On Wednesday, December 26, 2012 12:28:30 PM UTC-5, Lucas Leemann wrote:
Hi all,

I had some code which I used two months ago and it ran without any problems. Now, after downloading rstan 1.1.0 I get error messages and they are not clear (e.g. no matches for function name="inv_logit").

The full parser output is

INVALID COMMAND-LINE ARGUMENT
EXPECTATION FAILURE LOCATION
: file=/tmp/SU/LL/code.stan; line=69, column=135

                                       
(1- inv_logit(alpha34 + beta34i1*x34i1[n] + beta34i2*x34i2[n])*(alpha24 + beta24*x24[n]) + alpha22 + beta22*x22[n])
                                                                                                                                     
^-- here


DIAGNOSTIC
(S) FROM PARSER:

no matches for function name="inv_logit"

    arg
0 type=row vector
no matches for function name="multiply"
    arg
0 type=ill formed
    arg
1 type=real
no matches for function name="subtract"
    arg
0 type=int
    arg
1 type=ill formed
no matches for function name="add"
    arg
0 type=ill formed
    arg
1 type=real
no matches for function name="add"
    arg
0 type=ill formed
    arg
1 type=real
expression
is ill formed
Parser expecting: <eps>

Execute "stanc --help" for more information


This means that there is no definition of the inv_logit() function that inputs a row_vector. If you look at the index of the Stan manual, the inv_logit() function is only defined for a real (scalar).  The reason it is a row_vector is because these

row_vector[N] x34i1[N];
row_vector
[N] x34i2[N];

are declared as row_vectors in the data block. If this somehow worked before, it was probably a bug in Stan. Perhaps you intended these to be arrays of length N? Or maybe you intended beta34i1 and beta34i2 to be column vectors but in that case, you would need to post-multiply the data by the coefficients to get a scalar. Whatever the case may be, inv_logit() is going to output a scalar so you need to input something that evaluates to a scalar.

Ben


Lucas Leemann

unread,
Dec 27, 2012, 1:04:27 PM12/27/12
to stan-...@googlegroups.com
Hi Ben,

Thank you very much for your help and clarifying why it is not running anymore. Is there a vectorized version for inv_logit or is that planned to be in a future release?

Best,
Lucas

Bob Carpenter

unread,
Dec 27, 2012, 1:31:14 PM12/27/12
to stan-...@googlegroups.com
There isn't a vectorized inv_logit, but we're working
on vectorizing all of the univariate scalar functions
to give them signatures:

(real):real

(real[]):real[]

(vector):vector

(row_vector):row_vector

(matrix):matrix

Then we might also want to have all the vectors of these
things, such as for an array of vectors:

(vector[]):vector[]

Right now, our priorities are speeding up all the probability function and
matrix op gradient calculations (the main speed bottleneck), vectorizing the
multivariate probability functions, and adding cumulative distribution functions
(which require a bunch of new special functions for gradients).

So vectorizing the basic functions is probably still a few months out.

- Bob
> --
>
>

Daniel Lee

unread,
Dec 27, 2012, 1:42:16 PM12/27/12
to stan-...@googlegroups.com
On Thu, Dec 27, 2012 at 1:31 PM, Bob Carpenter <ca...@alias-i.com> wrote:
There isn't a vectorized inv_logit, but we're working
on vectorizing all of the univariate scalar functions
to give them signatures:

   (real):real

   (real[]):real[]

   (vector):vector

   (row_vector):row_vector

   (matrix):matrix

Then we might also want to have all the vectors of these
things, such as for an array of vectors:

   (vector[]):vector[]

Right now, our priorities are speeding up all the probability function and
matrix op gradient calculations (the main speed bottleneck), vectorizing the
multivariate probability functions, and adding cumulative distribution functions
(which require a bunch of new special functions for gradients).

So vectorizing the basic functions is probably still a few months out.

The fastest way to determine whether a function has been vectorized is to look at the function index at the end of the user's manual. On page 230 of the v1.1.0 version of the manual, inv_logit() shows as having a signature of "(real x):real". When it is vectorized, it will show have the rest of the signatures Bob listed.

If anyone would like to help with vectorizing functions, please send an email to d...@mc-stan.org


Ben Goodrich

unread,
Dec 27, 2012, 2:37:24 PM12/27/12
to stan-...@googlegroups.com
On Thursday, December 27, 2012 1:04:27 PM UTC-5, Lucas Leemann wrote:
Thank you very much for your help and clarifying why it is not running anymore. Is there a vectorized version for inv_logit or is that planned to be in a future release?

As Bob and Daniel said, there will eventually be an inv_logit() that takes a unrestricted K-vector and returns a vector on (0,1)^K. But there is never going to be an inv_logit() function that takes a vector and returns a scalar, which is what your code was attempting to do.

Ben

Reply all
Reply to author
Forward
0 new messages