Initialization in cmdStan with fixed and randomized parameters

121 views
Skip to first unread message

Manuel Sapage

unread,
Mar 28, 2017, 12:08:08 PM3/28/17
to Stan users mailing list

Hello Stan Community,

I am relatively new to Stan and I am struggling with one problem. I am creating a model with N+2 parameters:

parameters {
  real alpha;
  real beta;
  vector<lower=0>[N] lambda;
}


I would like to initialize alpha and beta to the value 3 and let Stan handle the vector lambda. In RStan I can simply write:

fit <- stan(file="pois_g1.stan",data=stan_data,chains=1,init=list(list(alpha=3,beta=3)))


I tried to do the same in cmdStan by creating an init.R file with the following

alpha <- 3
beta <- 3

But I always get the error:

Initialization from source failed.
variable lambda missing

It runs fine without the init.R file so I know it is a problem of initialization. How do I create an init.R file for cmdStan that allows for fixed alpha and beta while allowing Stan to handle the vector lambda of size N?

Thanks.




Daniel Lee

unread,
Mar 28, 2017, 12:44:48 PM3/28/17
to stan-...@googlegroups.com
What version of cmdstan are you using? I thought the latest version allows partial initialization. 



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.

Manuel Sapage

unread,
Mar 28, 2017, 1:05:38 PM3/28/17
to Stan users mailing list
I am using version CmdStan 2.14.0. I think is the latest version.

Bob Carpenter

unread,
Mar 29, 2017, 1:02:22 AM3/29/17
to stan-...@googlegroups.com
You shouldn't need to initialize anything in simple models.
Does the model not fit with fully Stan-generated random inits?

The place where random inits go bad is if you have upper and lower
bounds, because Stan tries to initialize around the middle of the range.

With the develop version of CmdStan I don't have a problem with
partial inits. Are you sure you're using 2.14? I don't think the inits
have been changed in develop since then.

- Bob




> On Mar 28, 2017, at 12:08 PM, Manuel Sapage <manuela...@gmail.com> wrote:
>
>

Manuel Sapage

unread,
Mar 29, 2017, 7:19:38 AM3/29/17
to Stan users mailing list
Problem solved. It turned out to be an installation problem. I uninstalled and installed everything back and it worked fine.

Stan-generated random units converts just fine. I wanted to use custom priors because I am translating my code from JAGS and wanted to test the parameters using the same priors.

Thanks!
Reply all
Reply to author
Forward
0 new messages