Also, everyone else -- I managed to generate
a Stan function index. The only problem is that
the underscore isn't searchable in Preview in our
docs. Who knows what pdflatex is generating.
PDFs are suboptimal for search, as I've
noted before for Acrobat (Matt -- please go kick some
corporate butt on this matter):
http://lingpipe-blog.com/2007/03/18/a-pdfn-mess/
Also, everyone else -- I managed to generate
a Stan function index. The only problem is that
the underscore isn't searchable in Preview in our
docs. Who knows what pdflatex is generating.
PDFs are suboptimal for search, as I've
noted before for Acrobat (Matt -- please go kick some
corporate butt on this matter):
http://lingpipe-blog.com/2007/03/18/a-pdfn-mess/
On Sep 22, 2012 5:22 PM, "Andrew Gelman" <gel...@stat.columbia.edu> wrote:
>
> Just tell me when they're in the current downloadable stan and I'll give them a try.
> A
They will be available in 1.0.2. ETA is next Stan meeting +/- a day.
y ~ normal(scalar, scalar);
Thanks,--
Ben
goodrich@CYBERPOWERPC:/tmp/2D$ cat twoD.stan
parameters {
real y[3,2]; // or matrix[3,2] y;
}
model {
y ~ normal(0.0,1.0);
}
goodrich@CYBERPOWERPC:/opt/stan$ make O=0 /tmp/2D/twoD
--- Translating Stan graphical model to C++ code ---
bin/stanc /tmp/2D/twoD.stan --o=/tmp/2D/twoD.cpp
Model name=twoD_model
Input file=/tmp/2D/twoD.stan
Output file=/tmp/2D/twoD.cpp
INVALID COMMAND-LINE ARGUMENT
LOCATION: file=/tmp/2D/twoD.stan; line=5, column=3
y ~ normal(0.0,1.0);
^-- here
DIAGNOSTIC(S) FROM PARSER:
no matches for function name="normal_log"
arg 0 type=real[2]
arg 1 type=real
arg 2 type=real
unknown distribution=normal
Parser expecting: "}"
I haven't thought about how to generalize to multidimensional matrices
and 2d arrays yet. Can we define a consistent behavior for the
distributions? I'm guessing that you want:
matrix ~ normal(scalar, scalar)
to mean that each element in the matrix should be treated as y in the
distribution.
That makes sense, but then what should be the
appropriate behaviors for things like:
matrix ~ normal(matrix, vector)
or
matrix ~ normal(vector, row_vector)
or
matrix[3,2] ~ normal(matrix[3,1], matrix[1,2]) (where dim is in the
square brackets)
If we can define consistent behavior, we can try to beef up the
VectorView stuff to do what we want. I really haven't thought about
these things too much, so maybe there's a simple answer to all of
this.
On Friday, October 12, 2012 12:16:36 PM UTC-4, Daniel Lee wrote:I haven't thought about how to generalize to multidimensional matrices
and 2d arrays yet. Can we define a consistent behavior for the
distributions? I'm guessing that you want:
matrix ~ normal(scalar, scalar)
to mean that each element in the matrix should be treated as y in the
distribution.
Yes. Just flatten whatever is on the left-hand side.
That makes sense, but then what should be the
appropriate behaviors for things like:
matrix ~ normal(matrix, vector)
or
matrix ~ normal(vector, row_vector)
or
I would say throw exception unless everything is the same size or is a scalar.
matrix[3,2] ~ normal(matrix[3,1], matrix[1,2]) (where dim is in the
square brackets)
I would have guessed that that was already legal, but if not it should be.
If we can define consistent behavior, we can try to beef up the
VectorView stuff to do what we want. I really haven't thought about
these things too much, so maybe there's a simple answer to all of
this.
I don't think there is a simple answer for the
multidimensional ~ normal(multidimensional, multidimensional)
case unless all the multidimensional objects are the same dimension. R recycles and throws a warning if recycling doesn't come out right, but I think Stan should only recycle scalars.
On Friday, October 12, 2012 12:16:36 PM UTC-4, Daniel Lee wrote:I haven't thought about how to generalize to multidimensional matrices
and 2d arrays yet. Can we define a consistent behavior for the
distributions? I'm guessing that you want:
matrix ~ normal(scalar, scalar)
to mean that each element in the matrix should be treated as y in the
distribution.
Yes. Just flatten whatever is on the left-hand side.Would we also flatten the others parameters as well? We currently make no distinction between the arguments in the c++ distribution function. I just want to be clear as to what happens when the lhs is a 3x2 matrix and a parameter is a 2x3 matrix.
Or perhaps a 3 vector or a 6 vector.
That makes sense, but then what should be the
appropriate behaviors for things like:
matrix ~ normal(matrix, vector)
or
matrix ~ normal(vector, row_vector)
or
I would say throw exception unless everything is the same size or is a scalar.
matrix[3,2] ~ normal(matrix[3,1], matrix[1,2]) (where dim is in the
square brackets)
I would have guessed that that was already legal, but if not it should be.
We don't allow the lhs, but this is currently illegal. The lengths of the parameters do not match. One is length 3 and the other is length 2.
If we can define consistent behavior, we can try to beef up the
VectorView stuff to do what we want. I really haven't thought about
these things too much, so maybe there's a simple answer to all of
this.
I don't think there is a simple answer for the
multidimensional ~ normal(multidimensional, multidimensional)
case unless all the multidimensional objects are the same dimension. R recycles and throws a warning if recycling doesn't come out right, but I think Stan should only recycle scalars.
What does "recycling" mean?
> set.seed(12345)
> rnorm(6, mean = 0:2, sd = 4:5) # implicit recycling
[1] 2.342115 4.547330 1.562787 -2.267486 3.423550 -7.089780
> set.seed(12345)
> rnorm(6, mean = c(0:2, 0:2), sd = c(4:5, 4:5, 4:5)) # explicit recycling
[1] 2.342115 4.547330 1.562787 -2.267486 3.423550 -7.089780
Option 3. The in between spec would be to require the sizes
to all match, and if there are matrices and/or arrays,
their dimensions all have to match.