stan-dev / stan-dev/rstan

Uninformative error message with incorrect usage of 'fit' argument

Open
#723 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

Passing a string or model code to the fit argument results in an error about the wrong algorithm being used, rather than the wrong argument.

Description:

As discovered by a user on the forum.

When calling: stan(fit = stan_code,...) where stan_code is a string (rather than stanfit object), the model compiles and then returns an error about needing to use the fixed_param algorithm. This doesn't make it clear the problem is with the argument to stan() and not the choice of sampler.

Reproducible Steps:
library(rstan) 
stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'
out = stan(fit = stancode,data=list(y_mean=0))

SAMPLING FOR MODEL '81051bcc2cf1bedf378224b0a93e2877' NOW (CHAIN 1).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "                      
[2] "  Must use algorithm=\"Fixed_param\" for model that has no parameters."
[1] "error occurred during calling the sampler; sampling not done"
RStan Version:

2.19.2

R Version:

R version 3.6.1 (2019-07-05)

Operating System:

Windows 10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the stan() entry point and reproduce the reported call with a string passed to fit, using the RStan and R versions shown. Trace where the fit argument is handled before sampling. Done means the same misuse reports that fit must be a stanfit object, rather than suggesting the fixed_param algorithm.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.