Using Stan in R:Some errors are occurring and can't solve...

maeken

New member
Joined
Jan 22, 2020
Messages
2
Some errors below are occurring while using Stan in R. Could you tell me how to fix them? I also put the data below, which have something wrong with.

1: readLines(file, warn = TRUE) :
There were incomplete line in the last, 'C:\Users\km\Documents\base.stan'
2: There were 222 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
3: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See
http://mc-stan.org/misc/warnings.html#bfmi-low
4: Examine the pairs() plot to diagnose sampling problems

5: The largest R-hat is 1.22, indicating chains have not mixed.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#r-hat
6: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#bulk-ess
7: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#tail-ess


data{
int N;
int M;
int G;
vector[N] y;
vector[N] hr;
int teamID[N];
}
parameters{
real alpha;
real beta[G];
real gamma;
real<lower=0> sigma;
real<lower=0> tau;
}
model{
vector[N] mu;
for(i in 1:N) mu=alpha+hr*beta[teamID];
y~normal(mu,sigma);
beta~normal(gamma,tau);
alpha~normal(0,100);
gamma~normal(0,100);
sigma~cauchy(0,5);
tau~cauchy(0,5);
}

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

base_dat<-list(N=136,
G=12,
M=2,
y=c(9.393,9.210,9.903,9.616,10.597,9.159,10.597,8.638,8.294,10.002,10.309,8.822,7.170,10.820,9.383,10.043,10.266,9.680,9.105,8.319,8.613,7.696,8.517,7.650,7.741,8.146,8.987,8.412,8.854,9.480,10.714,8.854,7.863,10.086,7.937,9.048,9.680,8.412,9.210,8.648,9.048,9.525,9.036,8.987,8.780,8.161,10.166,8.517,9.547,10.820,9.306,10.669,10.597,8.294,8.161,8.294,7.496,10.065,7.824,8.294,7.741,8.700,7.601,9.210,10.597,8.923,7.244,8.987,7.824,7.272,7.496,7.601,8.389,8.189,9.903,8.039,7.937,10.404,7.390,9.547,8.854,10.820,8.764,8.006,7.601,8.243,8.780,9.798,9.210,9.210,10.086,10.240,8.854,9.105,8.161,10.240,9.616,9.210,9.999,10.567,8.700,8.882,9.798,7.378,8.294,7.244,8.962,9.210,10.597,8.613,8.161,8.795,10.597,7.244,8.517,8.294,7.696,7.601,8.455,7.937,9.616,7.871,9.798,7.863,7.601,8.537,8.132,10.951,9.210,10.309,7.601,7.901,9.680,9.210,9.127,7.863),
hr=c(13,15,15,9,15,41,29,3,25,38,26,11,9,9,26,26,25,11,3,4,1,1,24,9,3,3,33,2,18,7,39,13,0,13,4,26,28,4,9,1,5,8,9,4,7,11,11,10,3,18,47,34,16,1,3,1,5,24,2,2,2,2,2,12,32,22,0,16,5,2,7,7,2,10,10,6,0,10,1,3,3,32,1,11,4,4,14,7,2,2,14,28,8,5,5,25,5,1,13,1,2,3,10,2,18,7,11,0,38,3,5,4,8,12,8,5,1,1,13,1,14,5,9,1,3,7,5,36,11,10,6,5,30,8,13,2),
teamID=c(10,5,12,8,3,4,8,6,1,2,5,10,1,7,11,4,10,3,10,1,4,6,11,9,11,12,3,11,7,11,3,3,5,1,3,10,4,5,9,7,12,7,4,7,8,5,8,12,2,3,7,2,6,6,4,10,10,7,3,6,10,3,10,1,8,8,6,7,4,11,9,9,11,2,9,1,10,2,9,2,8,12,4,6,3,10,9,5,5,4,8,7,11,2,6,9,3,9,1,6,9,11,1,3,12,9,12,12,4,5,11,12,8,12,6,2,10,11,5,10,6,11,5,6,8,12,1,8,2,3,6,4,1,11,1,8)
)
fit<-stan(file='base.stan',data=base_dat,iter=1000,chains=3)
 
Some error below are occurring while using Stan in R.

Could you tell me how to fix them? I also put the data below, which have something wrong with.



1: readLines(file, warn = TRUE) :

There were incomplete line in the last, 'C:\Users\km\Documents\base.stan'

2: There were 222 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See

http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup

3: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See

http://mc-stan.org/misc/warnings.html#bfmi-low

4: Examine the pairs() plot to diagnose sampling problems



5: The largest R-hat is 1.22, indicating chains have not mixed.

Running the chains for more iterations may help. See

http://mc-stan.org/misc/warnings.html#r-hat

6: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.

Running the chains for more iterations may help. See

http://mc-stan.org/misc/warnings.html#bulk-ess

7: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.

Running the chains for more iterations may help. See

http://mc-stan.org/misc/warnings.html#tail-ess



スクリーンショット 2020-01-22 19.58.37.png
 
Top