Hi all
I am trying to recreate the multivariate regression example from page 92 (section 9.9) in the most recent Rstan manual, as it fits the type of analysis that I want to run on a psychological experiment.
My goal is to adjust the subject level data (‘groups’) that I have with the population/group-level predictors. Each subject undertakes 22 trials in a decision-making task, with binary responses. Hence I am using a linear regression model at the group level and a logistic function at the subject level.
My problem is that I am running into a well-documented problem: I am creating a row-vector in line 27 when multiplying the group predictors (u[s]) with gamma. the multi-normal function only accepts vectors as inputs:
Error in stanc("GBE_hierarchical_logistic_linear.stan") :
failed to parse Stan model 'GBE_hierarchical_logistic_linear' with error message:
EXPECTATION FAILURE LOCATION: file=input; line=27, column=56
beta[s] ~ multi_normal((u[s] * gamma), Sigma_beta);
^-- here
DIAGNOSTIC(S) FROM PARSER:
no matches for function name="multi_normal_log"
arg 0 type=vector
arg 1 type=row vector
arg 2 type=matrix
available function signatures for multi_normal_log:
0. multi_normal_log(vector, vector, matrix) : real
unknown distribution=multi_normal
Parser expecting: <eps>
I simulated data to test this model. The simulated data is structured as follows: 50 subjects, three parameters to be estimated per subject, two group predictors, each subject's true parameters are drawn from a normal distribution, with non-zero mean and std. of 3.
My questions:
1. Since I have exactly recreated the example rstan code given on page 95; I wonder whether I made a mistake or whether the example as described in the manual cannot currently be run in rstan given the row_vector restriction in the multi_normal function.
2. As my data has to be structured the way it is set up, I wonder whether there is a work around for me? I saw that the issue (#589) is fixed on the development platform.
Please find attached my stan code; a matlab file that simulates data; the matlab data output (mat file); the code that runs the rstan model. Note that R.matlab has to be installed to read the mat file into R.
For some reason the file upload isn't working, here's a dropbox link: https://www.dropbox.com/sh/hx7gqkcy3b3sjah/AACIyOcjzXmNY76Xx89d0mf4a
Thank you very much for your help in advance!
Daniel
Hi BobSorry that I have to bother you with this again. I just updated to the new rstan version, however the error persists (see in red at the end of this post).
I tried to transpose, as you suggested but that doesnt work either. I am not sure whether transforming beta (either by transposing or changing beta to an array of vectors) would change anything, as rstan seems to complain about the (u[s] * gamma) operation.
Has the multi_normal issue not been fixed? What should I do?