# Hello,I am new user and I need help.Ιnside Ε[i, m] what will it add each time?! The first time and with ( j in 1:1) it will add E [1, m] (I'm not sure). The next ones?!

``````for (m in 1:M){
E[1, m]= 0.002 .* n[1,m];
for (i in 2:t){
for(j in 1:(i-1)){
E[i,m] += n[j,m] * roy[i-j,m] ;
}
}
}
``````

for simple questions of what does the language do? how does assignment work? etc, here’s a trick that might help you: you can test the Stan language constructs by writing Stan programs which consist only of a `transformed data` block and use the Stan `print` statement to check what happens at each step.

you would then run your program using the `sample` method with algorithm specified as `fixed_params` and you should only run 1 iteration of sampling. the print statements will be output to the console and you can see what’s going on.

2 Likes

I will run it with rstan because I use mainly R and just try to read a model that is written in STAN

How can I do what you say?

1. write a program
2. run it - this example is using CmdStan, but it would be roughly the same in cmdstanr or rstan.
``````~/.cmdstan/cmdstan-2.25.0> cat foo.stan
transformed data {
int  N = 10;
int y[N] = { 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 };
for (n in 1:N)
print(y[n]);
}
~/.cmdstan/cmdstan-2.25.0> ./foo sample num_samples=1 num_warmup=0 algorithm=fixed_param
method = sample (Default)
sample
num_samples = 1
num_warmup = 0
(...)

0
1
0
0
1
0
0
1
0
0
Iteration: 1 / 1 [100%]  (Sampling)

Elapsed Time: 0 seconds (Warm-up)
0 seconds (Sampling)
0 seconds (Total)

``````

terminal output will be different for different interfaces, but you will see the 0’s and 1’s for each iteration of the for loop.

print statements documented here: https://mc-stan.org/docs/2_25/reference-manual/print-statements-section.html

good luck!

1 Like