sampling function gives out is.na warnings

156 views
Skip to first unread message

andy...@cubist-asia.com

unread,
Aug 11, 2015, 6:08:41 AM8/11/15
to Stan users mailing list
Hi all,

Not sure if this is critical. But, it seems that sampling function would give out a bunch of is.na(x) warning messages:

R output:
......

Chain 4, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 4, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 2.32086 seconds (Warm-up)
#                2.32896 seconds (Sampling)
#                4.64982 seconds (Total)

Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
Warning messages:
2: In FUN(X[[i]], ...) :1:  data with name time is not numeric and not used
In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
2: In FUN(X[[i]], ...) :Warning messages:
 data with name time is not numeric and not used
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
2: In FUN(X[[i]], ...) : data with name time is not numeric and not used
[1]Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
2: In FUN(X[[i]], ...) : data with name time is not numeric and not used
 "done"
Inference for Stan model: stan_est_market_eff_fit.
4 chains, each with iter=10000; warmup=5000; thin=1;
post-warmup draws per chain=5000, total post-warmup draws=20000.

                            mean se_mean      sd     2.5%     25%    50%    75%
rmse_static                 0.38    0.00    0.03     0.32    0.36   0.38   0.40
rmse_static_sd              0.08    0.00    0.14     0.01    0.03   0.04   0.06
learn_rate                 -0.39    0.00    0.13    -0.75   -0.41  -0.35  -0.32
learn_sd                    0.04    0.00    0.01     0.02    0.03   0.03   0.04
lp[1]                    -364.05   56.98 1140.42 -3992.11 -123.96 -23.15  12.38
lp[2]                    -283.83   46.76  936.91 -3270.23  -81.24  -2.62  22.57
lp[3]                    -216.86   37.77  770.64 -2643.17  -46.44  13.09  27.74
lp[4]                    -159.16   29.91  628.38 -2083.25  -17.57  22.51  30.97
lp[5]                    -111.43   23.09  505.30 -1603.96    0.80  27.41  34.41
lp[6]                     -74.08   17.33  405.66 -1198.86    0.10  30.38  36.58
lp[7]                     -48.02   12.92  367.85  -857.73   -4.99  29.93  36.73
....

R code:
N_d <- 20

mkt_forecast_error <- c(
            0.37733820,             0.34814320,             0.37601800,
            0.39766186,             0.40671559,             0.37047201,
            0.32281526,             0.29462281,             0.30124360,
            0.29665000,             0.30814859,             0.28484706,
            0.26505298,             0.29368737,             0.28023730,
            0.19997346,             0.17094374,             0.14203103,
            0.12186337,             0.08997575
);

mkt.error.fit <- sampling (EA.stanEngine.model.estMarketEff.fit,
                               iter=10000, chains=4);
print ("done");

Many thanks,
Andy

Bob Carpenter

unread,
Aug 11, 2015, 1:31:56 PM8/11/15
to stan-...@googlegroups.com
This looks like something that should be fixed. Would you
mind creating an issue on stan-dev/rstan or replying to this
message with the exact sequence of R calls that produce this
problem, preferably with as little model and data as possible.

Thanks.

- Bob
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Andy Choi

unread,
Aug 12, 2015, 5:58:44 AM8/12/15
to stan-...@googlegroups.com
HI Bob:

R code and STAN code attached.

R output as follow:
> source ("t1.r")
COMPILING THE C++ CODE FOR MODEL 't1' NOW.

SAMPLING FOR MODEL 't1' NOW (CHAIN 1).

Chain 1, Iteration:    1 / 10000 [  0%]  (Warmup)
Chain 1, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 1, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 1, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 1, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 1, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 1, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 1, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 1, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 1, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 1, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 1, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.31037 seconds (Warm-up)
#                1.50556 seconds (Sampling)
#                2.81594 seconds (Total)


SAMPLING FOR MODEL 't1' NOW (CHAIN 2).

Chain 2, Iteration:    1 / 10000 [  0%]  (Warmup)
Chain 2, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 2, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 2, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 2, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 2, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 2, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 2, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 2, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 2, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 2, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 2, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.30599 seconds (Warm-up)
#                1.11006 seconds (Sampling)
#                2.41606 seconds (Total)


SAMPLING FOR MODEL 't1' NOW (CHAIN 3).

Chain 3, Iteration:    1 / 10000 [  0%]  (Warmup)
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 40:
stan::math::normal_log: Location parameter[1] is inf, but must be finite!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Chain 3, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 3, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 3, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 3, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 3, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 3, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 3, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 3, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 3, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 3, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 3, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.35657 seconds (Warm-up)
#                1.56896 seconds (Sampling)
#                2.92554 seconds (Total)


SAMPLING FOR MODEL 't1' NOW (CHAIN 4).

Chain 4, Iteration:    1 / 10000 [  0%]  (Warmup)
Chain 4, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 4, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 4, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 4, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 4, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 4, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 4, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 4, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 4, Iteration: 8000 / 10000 [ 80%]  (Sampling)

Chain 4, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 4, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.32582 seconds (Warm-up)
#                1.3296 seconds (Sampling)
#                2.65542 seconds (Total)


Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/Qpm8K5wbRGo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
t1.r
t1.stan

Jiqiang Guo

unread,
Aug 12, 2015, 9:59:09 AM8/12/15
to stan-...@googlegroups.com
What if you specify the data argument for function sampling? 

Jiqiang 

Andy Choi

unread,
Aug 12, 2015, 10:14:00 PM8/12/15
to stan-...@googlegroups.com
it's the same:

R code:

N_d <- 20

forecast_error <- c(
            0.37733820,             0.34814320,             0.37601800,
            0.39766186,             0.40671559,             0.37047201,
            0.32281526,             0.29462281,             0.30124360,
            0.29665000,             0.30814859,             0.28484706,
            0.26505298,             0.29368737,             0.28023730,
            0.19997346,             0.17094374,             0.14203103,
            0.12186337,             0.08997575
);

t1 <- stan_model ("t1.stan", model_name = "t1");



mkt.error.fit <- sampling (t1,
    #EA.stanEngine.model.estMarketEff.fit,
                           data = list (N_d = N_d, forecast_error = forecast_error),
                           iter=10000, chains=4);
#print ("done");


Output:


> source ("t1.r")
COMPILING THE C++ CODE FOR MODEL 't1' NOW.

SAMPLING FOR MODEL 't1' NOW (CHAIN 1).

Chain 1, Iteration:    1 / 10000 [  0%]  (Warmup)
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 40:
stan::math::normal_log: Scale parameter is 0, but must be > 0!

If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Chain 1, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 1, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 1, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 1, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 1, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 1, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 1, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 1, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 1, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 1, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 1, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.86136 seconds (Warm-up)
#                1.55891 seconds (Sampling)
#                3.42026 seconds (Total)



SAMPLING FOR MODEL 't1' NOW (CHAIN 2).

Chain 2, Iteration:    1 / 10000 [  0%]  (Warmup)
Chain 2, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 2, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 2, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 2, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 2, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 2, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 2, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 2, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 2, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 2, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 2, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.45572 seconds (Warm-up)
#                1.38564 seconds (Sampling)
#                2.84135 seconds (Total)



SAMPLING FOR MODEL 't1' NOW (CHAIN 3).

Chain 3, Iteration:    1 / 10000 [  0%]  (Warmup)
Chain 3, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 3, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 3, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 3, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 3, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 3, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 3, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 3, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 3, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 3, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 3, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.60249 seconds (Warm-up)
#                1.81029 seconds (Sampling)
#                3.41279 seconds (Total)



SAMPLING FOR MODEL 't1' NOW (CHAIN 4).

Chain 4, Iteration:    1 / 10000 [  0%]  (Warmup)
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 40:
stan::math::normal_log: Scale parameter is 0, but must be > 0!

If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Chain 4, Iteration: 1000 / 10000 [ 10%]  (Warmup)
Chain 4, Iteration: 2000 / 10000 [ 20%]  (Warmup)
Chain 4, Iteration: 3000 / 10000 [ 30%]  (Warmup)
Chain 4, Iteration: 4000 / 10000 [ 40%]  (Warmup)
Chain 4, Iteration: 5000 / 10000 [ 50%]  (Warmup)
Chain 4, Iteration: 5001 / 10000 [ 50%]  (Sampling)
Chain 4, Iteration: 6000 / 10000 [ 60%]  (Sampling)
Chain 4, Iteration: 7000 / 10000 [ 70%]  (Sampling)
Chain 4, Iteration: 8000 / 10000 [ 80%]  (Sampling)
Chain 4, Iteration: 9000 / 10000 [ 90%]  (Sampling)
Chain 4, Iteration: 10000 / 10000 [100%]  (Sampling)
#  Elapsed Time: 1.36565 seconds (Warm-up)
#                1.97616 seconds (Sampling)
#                3.34181 seconds (Total)


Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
2: In FUN(X[[i]], ...) : data with name time is not numeric and not used



Bob Carpenter

unread,
Aug 12, 2015, 11:25:11 PM8/12/15
to stan-...@googlegroups.com
Thanks for the careful reporting. I just turned it into an
issue and hopefully someone will be able to sort it out:

https://github.com/stan-dev/rstan/issues/188

This may not happen for 2.7.1, since it's more of an annoyance
than a serious bug.

- Bob
Reply all
Reply to author
Forward
0 new messages