stan-dev / stan-dev/rstan

corr_matrix[1] does not work

Open
#768 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary:

"R Session Aborted" with corr_matrix[1].

Description:

When K = 1, corr_matrix[K] makes R crash. Is it possible to allow corr_matrix[1] so that we do not need to distinguish between univariate case and multivariate case?

Reproducible Steps:

test.stan:
data {
int<lower = 1> K;
}

parameters {
corr_matrix[K] omega;
vector<lower = 0>[K] tau;
}

transformed parameters {
cov_matrix[K] sigma = quad_form_diag(omega, tau);
}

model {
omega ~ lkj_corr(1);
tau ~ cauchy(0, 1);
}

run.R:
library(rstan)
fit <- stan('test.stan', data = list(K = 1), iter = 10000, chains = 1)

Current Output:

"R Session Aborted" on RStudio

RStan Version:

2.19.3

R Version:

4.0.0

Operating System:

MacOS 10.15.5

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 by running the provided test.stan with run.R using K = 1 and confirm the R session abort. Read the corr_matrix and lkj_corr handling involved in this minimal model; done means corr_matrix[1] runs without aborting while preserving the existing multivariate behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.