I'm trying to estimate the parameters of Smooth Transition Autoregressive (STAR) model.

62 views
Skip to first unread message

rnrn...@gmail.com

unread,
Jan 28, 2017, 10:06:59 AM1/28/17
to Stan users mailing list
I'm trying to estimate the parameters of Smooth Transition Autoregressive (STAR) model.
Specifically, I'm trying to estimate 'g' and 'c' which are parameters of the Transition function G(st;g,c) before doing all the parameters all together.
I specify STAR(1) model:
y(t) = (f01 + f02*y(t-1))*(1 - G(st;g,c)) + (f11 + f12*y(t-1))*G(st;g,c) + sigma * epsilon(t), epsilon(t)~i.i.d.(0,1)
and
G(st;g,c) = (1 + exp(-g*(st-c)))^(-1), g>0
where st = t/T and t=1,2,...,T.
Then, I preliminarily give a stan code [f01=0.1, f02=0.3, f11=0.5, f12=0.8] and estimate the 'g' and 'c' of the Transition function G(st;g,c).
However, the parameters are not estimated correctly.
Please let me know where I made a mistake.
Here is the stan code:

data {
 int<lower=0> T;
 real r[T];
 real<lower=0> G1;
}
parameters {
    real<lower=0> g;
    real c;
    real sigma;
}
transformed parameters {
    real<lower=0> G[T];
    G[1] = G1;
 for (t in 2:T){
  G[t] = (1 + exp(-g*((t/T)-c)))^(-1);
    }
}
model {
 for (n in 2:T){
        r[n] ~normal((0.1 + 0.3*r[n-1])*(1 - G[n]) + (0.5 + 0.8*r[n-1])*(G[n]) , sigma);
    }
}

Daniel Lee

unread,
Jan 28, 2017, 6:19:38 PM1/28/17
to stan-...@googlegroups.com
When you say it's not estimated correctly, what do you mean? Does it not converge? (Check rhat) Does it converge, but provide really wide estimates? Are you just looking at modes?

If you include the data generating script and the output, we probably could help. Without it, it's hard to tell you anything specific. The Stan program alone isn't enough to pin down the posterior geometry. 



Daniel
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rnrn...@gmail.com

unread,
Jan 28, 2017, 9:37:56 PM1/28/17
to Stan users mailing list

Hi, Lee!


I confirmed the rhat, but it does not seem to converge.

I do not know what the modes, so I probably can not check it.

How can I check the modes?


I am using MatlabStan.

The data generating script and the output are as follows.

The data generating script is:

f01 = 0.1;

f11 = 0.3;

f02 = 0.5;

f12 = 0.8;

g = 10;

c = 0.5;

sig = 1;

TT = 100;

y = zeros(TT,1);

G = zeros(TT,1);

y(1) = 1;

G(1) = (1 + exp(-g*( 1/TT -c))).^(-1);


for t=2:TT

st = t/TT;

G(t) = (1 + exp(-g*(st-c))).^(-1);

y(t) = (0.1 + 0.3*y(t-1))*(1 - G(t)) + (0.5 + 0.8*y(t-1))*G(t) + sig * normrnd(0,1);

end;

y

r = y;


rats_dat = struct('T',size(r,1),'r',r,'G1',size(r,1));


rats_fit1 = stan('file','ex2stan.stan','data',rats_dat,'iter',1000,'warmup',20,'thin',1,'chains',4);

rats_fit1.block()

print(rats_fit1);


g = rats_fit1.extract('permuted',true).g;

mean(g)


c = rats_fit1.extract('permuted',true).c;

mean(c)


sigma = rats_fit1.extract('permuted',true).sigma;

mean(sigma)




The output is:

Inference for Stan model: ex2stan_model

4 chains: each with iter=(1000,1000,1000,1000); warmup=(0,0,0,0); thin=(1,1,1,1); 4000 iterations saved.

Warmup took (0.020, 0.0090, 1.0, 1.0) seconds, 2.1 seconds total

Sampling took (0.62, 0.87, 0.60, 0.71) seconds, 2.8 seconds total

Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat

lp__ 6.2e+002 2.2e+001 1.3e+002 3.1e+002 6.5e+002 6.5e+002 38 14 1.1e+000

accept_stat__ 8.5e-001 4.0e-002 1.6e-001 5.0e-001 9.1e-001 1.0e+000 16 5.7 1.1e+000

stepsize__ 7.5e-002 1.2e-002 1.7e-002 5.2e-002 8.7e-002 9.5e-002 2.0 0.71 1.8e+014

treedepth__ 3.3e+000 1.8e-001 1.5e+000 1.0e+000 3.0e+000 6.0e+000 70 25 1.0e+000

n_leapfrog__ 2.3e+001 4.1e+000 3.5e+001 2.0e+000 1.5e+001 6.7e+001 71 25 1.0e+000

divergent__ 7.2e-001 3.4e-002 4.5e-001 0.0e+000 1.0e+000 1.0e+000 177 63 1.0e+000

energy__ -6.2e+002 2.2e+001 1.4e+002 -6.5e+002 -6.5e+002 -3.1e+002 38 14 1.1e+000

g 8.2e+307 inf inf 2.0e+162 8.6e+307 1.7e+308 4000 1427 nan

c -3.9e+001 1.8e+001 2.8e+001 -8.7e+001 -2.6e+001 -6.6e+000 2.4 0.85 3.1e+000

sigma 1.1e+000 1.3e-003 7.7e-002 9.5e-001 1.1e+000 1.2e+000 3424 1221 1.0e+000

G[1] 1.0e+002 2.2e-014 1.4e-012 1.0e+002 1.0e+002 1.0e+002 4000 1427 1.0e+000

G[2] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[3] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[4] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[5] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[6] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[7] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[8] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[9] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[10] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[11] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[12] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[13] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[14] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[15] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[16] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[17] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[18] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[19] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[20] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[21] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[22] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[23] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[24] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[25] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[26] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[27] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[28] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[29] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[30] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[31] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[32] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[33] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[34] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[35] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[36] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[37] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[38] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[39] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[40] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[41] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[42] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[43] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[44] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[45] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[46] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[47] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[48] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[49] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[50] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[51] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[52] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[53] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[54] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[55] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[56] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[57] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[58] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[59] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[60] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[61] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[62] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[63] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[64] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[65] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[66] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[67] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[68] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[69] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[70] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[71] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[72] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[73] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[74] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[75] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[76] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[77] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[78] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[79] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[80] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[81] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[82] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[83] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[84] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[85] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[86] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[87] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[88] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[89] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[90] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[91] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[92] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[93] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[94] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[95] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[96] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[97] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[98] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[99] 1.0e+000 6.2e-004 3.9e-002 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

G[100] 1.0e+000 1.2e-004 7.4e-003 1.0e+000 1.0e+000 1.0e+000 4000 1427 1.0e+000

Samples were drawn using hmc with nuts.

For each parameter, N_Eff is a crude measure of effective sample size,

and R_hat is the potential scale reduction factor on split chains (at

convergence, R_hat=1).

*** print is deprecated and will be removed in v3.0;

*** use stansummary instead


ans =


Inf



ans =


-39.1619



ans =


1.0670


ans stands for g, c and sigma in order from the top.

The values I really want to estimate are 10, 0.5 and 1.

If you need RStan data generating script, create it and attach it.




2017年1月29日日曜日 8時19分38秒 UTC+9 Daniel Lee:

Andrew Gelman

unread,
Jan 28, 2017, 9:41:33 PM1/28/17
to stan-...@googlegroups.com
warmup=(0,0,0,0) ?

Did you do zero warmup?  If so, that won't work.

But I don't know Matlab so maybe I'm missing something.
A

rnrn...@gmail.com

unread,
Jan 28, 2017, 9:58:01 PM1/28/17
to Stan users mailing list, gel...@stat.columbia.edu
warmup is set to 20.
The number of data is 100 pieces.
For some reason, the smaller warmup, the closer the g and c values you want to seek.
I also will try it in Rstan, so please give me some time.

2017年1月29日日曜日 11時41分33秒 UTC+9 Andrew Gelman:

Andrew Gelman

unread,
Jan 28, 2017, 10:03:13 PM1/28/17
to stan-...@googlegroups.com
20 warmup isn't very much.  We usually do 1000 warmup.

rnrn...@gmail.com

unread,
Jan 28, 2017, 10:26:05 PM1/28/17
to Stan users mailing list, gel...@stat.columbia.edu

I changed warmup from 20 to 1000, but the value does not converge as usual.

However, since it is still displayed as warmup=(0,0,0,0), there is a possibility that the value of warmup could not be changed.
I will try out various methods of change so please give me some time.



Inference for Stan model: ex2stan_model

4 chains: each with iter=(1000,1000,1000,1000); warmup=(0,0,0,0); thin=(1,1,1,1); 4000 iterations saved.

Warmup took (1.1, 0.19, 0.20, 0.21) seconds, 1.7 seconds total

Sampling took (0.50, 0.38, 0.42, 0.50) seconds, 1.8 seconds total

Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat

lp__ 6.4e+002 5.4e-002 1.3e+000 6.4e+002 6.4e+002 6.4e+002 543 302 1.0e+000

accept_stat__ 8.4e-001 4.0e-002 1.4e-001 5.0e-001 8.7e-001 1.0e+000 12 6.7 1.1e+000

stepsize__ 2.9e-001 1.1e-001 1.5e-001 1.2e-001 3.5e-001 5.0e-001 2.0 1.1 2.4e+014

treedepth__ 2.3e+000 4.2e-001 1.2e+000 0.0e+000 2.0e+000 4.0e+000 8.5 4.7 1.1e+000

n_leapfrog__ 8.8e+000 2.6e+000 7.4e+000 1.0e+000 7.0e+000 2.4e+001 7.8 4.4 1.1e+000

divergent__ 8.9e-001 7.1e-003 3.1e-001 0.0e+000 1.0e+000 1.0e+000 1881 1045 1.0e+000

energy__ -6.4e+002 6.2e-002 1.8e+000 -6.4e+002 -6.4e+002 -6.3e+002 809 450 1.0e+000

g 8.8e+307 inf inf 9.4e+306 8.8e+307 1.7e+308 4000 2223 nan

c -1.3e+003 1.4e+003 2.4e+003 -7.1e+003 -1.8e+002 -4.1e+001 2.9 1.6 2.7e+000

sigma 1.2e+000 3.4e-003 9.0e-002 1.1e+000 1.2e+000 1.4e+000 718 399 1.0e+000

G[1] 1.0e+002 2.2e-014 1.4e-012 1.0e+002 1.0e+002 1.0e+002 4000 2223 1.0e+000

G[2] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[3] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[4] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[5] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[6] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[7] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[8] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[9] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[10] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[11] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[12] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[13] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[14] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[15] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[16] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[17] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[18] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[19] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[20] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[21] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[22] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[23] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[24] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[25] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[26] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[27] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[28] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[29] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[30] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[31] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[32] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[33] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[34] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[35] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[36] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[37] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[38] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[39] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[40] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[41] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[42] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[43] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[44] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[45] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[46] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[47] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[48] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[49] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[50] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[51] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[52] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[53] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[54] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[55] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[56] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[57] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[58] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[59] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[60] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[61] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[62] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[63] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[64] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[65] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[66] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[67] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[68] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[69] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[70] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[71] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[72] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[73] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[74] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[75] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[76] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[77] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[78] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[79] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[80] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[81] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[82] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[83] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[84] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[85] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[86] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[87] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[88] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[89] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[90] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[91] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[92] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[93] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[94] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[95] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[96] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[97] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[98] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[99] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

G[100] 1.0e+000 1.1e-017 6.7e-016 1.0e+000 1.0e+000 1.0e+000 4000 2223 1.0e+000

Samples were drawn using hmc with nuts.

For each parameter, N_Eff is a crude measure of effective sample size,

and R_hat is the potential scale reduction factor on split chains (at

convergence, R_hat=1).

*** print is deprecated and will be removed in v3.0;

*** use stansummary instead


ans =


Inf



ans =


-1.3135e+03



ans =


1.2287



2017年1月29日日曜日 12時03分13秒 UTC+9 Andrew Gelman:

Daniel Lee

unread,
Jan 29, 2017, 8:32:31 AM1/29/17
to stan-...@googlegroups.com
I think warmup looks like 0 because CmdStan isn't saving warmup by default. 

g and C are estimated as roughly infinity. So why is that happening? I'll need to look at the model, but do you have priors on those parameters?

rnrn...@gmail.com

unread,
Jan 30, 2017, 1:25:44 AM1/30/17
to Stan users mailing list
I don’t have priors on those parameters.
I’m leaving them up to Stan.
If it seems that these priors cause the problems, should I set up them in the stan code by myself?

2017年1月29日日曜日 22時32分31秒 UTC+9 Daniel Lee:

Bob Carpenter

unread,
Jan 30, 2017, 3:30:44 PM1/30/17
to stan-...@googlegroups.com
That report is unfortunate, but I think Daniel's right. You're
getting the 1000 warmup iterations by default, but they're not
being saved by MatlabStan, so the summary has zero warmup.

Stan requires every parameter to have a proper posterior. If
you don't have a prior on a parameter and it's not constrained by
the likelihood, Stan will blow up.

You can find the mode with maximum likelihood estimation using optimization.
But it won't always exist, even when posterior means exist.

- Bob

rnrn...@gmail.com

unread,
Feb 1, 2017, 1:24:03 AM2/1/17
to Stan users mailing list

I set warmup when loading Stan code with Matlab.
I tried warmup=1 and warmup=1000.
Then, when warmup=1, R_hat became larger than 1.1, but when warmup=1000 it became R_hat = 1.0.(both g and c)
However, the value output by stan was warmup=(0,0,0,0) both when warmup=1 and warmup=1000.
I think that the setting of warmup probably went well, but what do you think?


Since I was receiving advice, I tried to give g and c various priors.
Then, the value of g successfully converged to the value I wanted.
Thank you very much.
Although the value of c has converged to an incorrect value, I would like to try giving various priors.


2017年1月31日火曜日 5時30分44秒 UTC+9 Bob Carpenter:

Andrew Gelman

unread,
Feb 1, 2017, 1:26:48 AM2/1/17
to stan-...@googlegroups.com
Never do warmup=1.  Default is warmup=1000 and post_warmup=1000.
A

Bob Carpenter

unread,
Feb 1, 2017, 1:42:12 AM2/1/17
to stan-...@googlegroups.com
And you want to test on simulated data to make sure
you recover the true value of the parameter in 50%
of the posterior 50% intervals (or 90% of the
posterior 90% intervals). Don't just look at the point
estimates.

- Bob

> On Feb 1, 2017, at 1:24 AM, rnrn...@gmail.com wrote:
>
>

rnrn...@gmail.com

unread,
Feb 6, 2017, 11:59:32 PM2/6/17
to Stan users mailing list
Sorry for my late reply.
I had estimated on the point so far.
As you taught me, I decided to estimate in the section.
I changed prior and I could safely estimate it.
Thank you so much for your help.

2017年2月1日水曜日 15時42分12秒 UTC+9 Bob Carpenter:

Brian Lau

unread,
May 17, 2017, 6:06:11 AM5/17/17
to Stan users mailing list
On Monday, January 30, 2017 at 9:30:44 PM UTC+1, Bob Carpenter wrote:
That report is unfortunate, but I think Daniel's right.  You're
getting the 1000 warmup iterations by default, but they're not
being saved by MatlabStan, so the summary has zero warmup.

Right, by default the warmup samples are not saved. The zeros listed in the summary come from CmdStan's summary. Since this comes up occasionally, I made a brief wiki page explaining how to save warmup samples:


-b
Reply all
Reply to author
Forward
0 new messages