Initialization failed after 100 attempts warning

665 views
Skip to first unread message

Angel Berihuete

unread,
Apr 21, 2013, 7:44:28 AM4/21/13
to stan-...@googlegroups.com
Dear stan users.

I want to analyse differences between stan and emcee (http://dan.iel.fm/emcee/) by using my dataset. My first attempt with stan has showed me this warning:

TRANSLATING MODEL 'imf_1slope' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'imf_1slope' NOW.
TESTING GRADIENT FOR MODEL 'imf_1slope' NOW (CHAIN 1).
Initialization failed after 100 attempts.  Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
error occurred during calling the sampler; sampling not done

I think I am trying to resolve a simple problem: only three variables and a unidimensional dataset (files attached) Please, any help will be welcome.

Thank you, 
Angel

PS. R version 2.15.3 (2013-03-01) -- "Security Blanket"
rstan (Version 1.2.0, packaged: 2013-03-06 21:47:56 UTC, GitRev: 1cde932d15a3)
DrawPointsAndSetUpStan.R
imf_1slope.stan

Ben Goodrich

unread,
Apr 21, 2013, 10:35:19 AM4/21/13
to stan-...@googlegroups.com
On Sunday, April 21, 2013 7:44:28 AM UTC-4, Angel Berihuete wrote:
Dear stan users.

I want to analyse differences between stan and emcee (http://dan.iel.fm/emcee/) by using my dataset. My first attempt with stan has showed me this warning:

TRANSLATING MODEL 'imf_1slope' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'imf_1slope' NOW.
TESTING GRADIENT FOR MODEL 'imf_1slope' NOW (CHAIN 1).
Initialization failed after 100 attempts.  Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
error occurred during calling the sampler; sampling not done

The problem seems to be with this:

transformed parameters {
  real cmfo
;
  cmfo
<- (pow(Mcomp,1-a)-pow(Mmax,1-a))/(1-a);
}

Since Mmax > Mcomp, if a < 1, then cmfo < 0. Thus, when you take the log() of cmfo in the model block, it is undefined.

Ben


Angel Berihuete

unread,
Apr 21, 2013, 1:59:13 PM4/21/13
to stan-...@googlegroups.com
Thank you Ben!

I defined a wrong constant for the likelihood function. Now all works!

cmfo <- (1-a)/(pow(Mmax,1-a)-pow(Mcomp,1-a))

 Angel
Reply all
Reply to author
Forward
0 new messages