Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizing fails on simple example when draws > 0 #580

Open
ksvanhorn opened this issue Nov 6, 2018 · 2 comments
Open

optimizing fails on simple example when draws > 0 #580

ksvanhorn opened this issue Nov 6, 2018 · 2 comments
Labels

Comments

@ksvanhorn
Copy link

ksvanhorn commented Nov 6, 2018

Summary:

Running the simple example given in the documentation for rstan::optimizing, but adding a nonzero value for draws, results in an error.

Description:

The documentation for rstan::optimizing gives the following example code:

m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- optimizing(m, hessian = TRUE)

This runs fine, but if I add a nonzero draws parameter

m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- optimizing(m, hessian = TRUE, draws=10)

it fails with this error:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

Reproducible Steps:

See above.

Current Output:

See above.

Expected Output:

Successful completion of call.

RStan Version:

2.18.1

R Version:

R version 3.4.3 (2017-11-30)

Operating System:

macOS High Sierra (version 10.13.6)

@ksvanhorn
Copy link
Author

ksvanhorn commented Nov 6, 2018

Same error if I do

m <- rstan::stan_model(model_code = 'data { int N; vector[N] y; } parameters {real mu;} model {y ~ normal(mu,1); }')
f <- rstan::optimizing(m, hessian = TRUE, draws=10, data=list(N=100, y=rnorm(100, 0.5, 1)))

But if I have two parameters the problem goes away:

m <- rstan::stan_model(model_code = 'data { int N; vector[N] y; } parameters {real mu; real<lower=0> sigma; } model {y ~ normal(mu,sigma); }')

@bob-carpenter
Copy link

I'd like to see regression tests added whenever this kind of stuff gets fixed. But I'd really like to see all the basic services tested for their various combinations of inputs and outputs to make sure they work. A good start would just to be to make sure that the basics work for each of the sampling, optimizing, and vb operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants