0
votes

The code of the model is,

data {
    int<lower=0> N;
    int<lower=0> K;
    matrix[N,K] y;
     matrix[N,K] X;
    
  }
   parameters {
     matrix[K,K] lambda_hat;
     matrix[K,K] sigma_0;
     matrix[K,K] L;
   }
   transformed parameters {
     matrix[N,K] mu;
     vector[4] v;
     for (i in 1:K)
       v[i]=1;
     
     for (i in 1:N)
       mu[i,]'=lambda_hat*x[i,]';

   }
   model {
     L~ wishart(K,diag_matrix(v));
     sigma_0~ wishart(K,L);
     lambda_hat~ wishart(K,L);
     for (t in 1:N)
       y[t,]'~ multi_normal(y[(t-1),]'+mu[t,]',sigma_0);
   }

I am having the following error when I run this code,

rt = stanc("mystancode.stan")

The error obtained is, *SYNTAX ERROR, MESSAGE(S) FROM PARSER: Illegal statement beginning with non-void expression parsed as transpose(mu[i, :]) Not a legal assignment, sampling, or function statement. Note that

  • Assignment statements only allow variables (with optional indexes) on the left;
  • Sampling statements allow arbitrary value-denoting expressions on the left.
  • Functions used as statements must be declared to have void returns

error in 'model2e850c17b4_mystancode' at line 20, column 7

18:      
19:      for (i in 1:N)
20:        mu[i,]'=lambda_hat*x[i,]';
          ^
21: 

PARSER EXPECTED: Error in stanc("mystancode.stan") : failed to parse Stan model 'mystancode' due to the above error.*

Looks like you cannot use a transpose at the left side of an assignment. If you do mu[i,]=lambda_hat*x[i,], that does not work? - Stéphane Laurent