List structures in Stan


#1

Hello,

is there any plan to insert lists in Stan language?

I think they could be quite powerful, because sometimes a collection of arrays do not have the same length.

For example, recently I found myself in the situation of needing this:

phi = simplex[P,Q,M]

For example [simplex[3], simplex[2], simplex[5]]
In the way to constrain by groups

simplex[3] * 0.2 + simplex[2] * 0.4 + simplex[5] * 0.4 = 1

or in a constrained sum of Bob

if I could program alpha_raw as list I could deal with any hierarchy without hard coding in the model


#2

If by list you mean tuple, then I would say there is a plan but zero progress.


#3

Thanks for the info!


#4

There is a trick for this in the manual, if you were not aware;

data {
int<lower=0> N; // # observations
int<lower=0> K; // # of groups
vector[N] y; // observations
int s[K]; // group sizes
...
model {
int pos;
pos = 1;
for (k in 1:K) {
segment(y, pos, s[k]) ~ normal(mu[k], sigma);
pos = pos + s[k];
}

#5

I need the STAN software would you to give link for downloading this please…


#6

http://mc-stan.org/interfaces/


#7

I need the command for the bayesian Generalized method of moment in STAN software please any help me


#8

There isn’t one and as far as I know, no one has gotten anything like that to work in Stan.


#9

As i know that bayesian Generalized method of moment have been done in STAN
software please
bgoodri http://discourse.mc-stan.org/u/bgoodri help me about that


#10

I am not aware of GMM stuff being done in Stan and my guess is that it wouldn’t work well.


#11

please check the following links in google
" https://webcache.googleusercontent.com/search?
q=cache:6q220XUeJ_0J:https://groups.google.com/d/topic/stan-
users/TWsGQytpYLQ+&cd=1&hl=en&ct=clnk&gl=pk "


#12

I remember that, but I am still skeptical that it would often work well. You basically just do what that guy did with a

target += -0.5 * quad_form(U, inverse_spd(Sigma));

where U and Sigma are the same as in the GMM objective function.


#13

this is just discussion and correction between these guys of a complete coding in STAN . And we have to find out the complete coding for Bayesian GMM in STAN please help me.


#14

It depends on what your moment equations are, which define U and Sigma. Once you have those it is just priors and

target += -0.5 * quad_form(U, inverse_spd(Sigma));

#15

I have a econometric model and now I want to estimate the model through Bayesian Generalized Method of moment
For conjugate prior
Library(mcmcpack)

model1<-MCMCregress(lngdp~to+lnk2+fd+corr, b0=c(0,1,-1,2,1), Bo = B1, sigma.mu=5,sigma.var=25, data=aa,mcmc=100000,burnin=50000)


#16

GMM is not in the top five ways I would estimate a linear regression model, but I suppose you could try. Your moment conditions are

vector[K] U = (transpose(X) * (y - X * beta)) / N;
matrix[K,K] Sigma = rep_matrix(0, K, K);
for (i in 1:N) {
  row_vector[K] x_i = X[i,];
  Sigma = Sigma + crossprod(x_i * (y[i] - x_i * beta));
}
Sigma = Sigma / N;
target += -0.5 * quad_form(U, inverse_spd(Sigma));

From there, you can use whatever prior distributions you want; conjugacy is irrelevant to Stan.


#17

Sir I have estimated the model classical ways as will as with bayesian ways
with different prior like conjugate, diffuse, improper uniform and weakly
informative priors and now I would like to estimate the model parameter
through Bayesian Generalized method of moment. In the initial stage of
Bayesian GMM I have no idea that how I start it please guide me about
Bayesian GMM


#18

Sir please guide me about Bayesian GMM


#19

my simple linear regression model is ( " Y = intercept + slope1(TO) +
slope2(KD) + slope3(FD) + slope4(CORR) + error " ). Now I want estimate the
model through Bayesian Generalized method of moment please help me.


#20

(

This discussion digressed a little from the title of the conversation. Maybe it would be useful for other users to transfer it into a conversation with a related name (?)

)

Cheers.