stan-dev / stan-dev/rstan

Sparse matrix in R incompatible with STAN

Open
#882 2 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:

Integrate R's sparse matrix class from the Matrix library with STAN.

Description:

When I use the Sparse Matrix class in R, provided by the Matrix package, my data-set is ~ 10 Mb. But when I call an RStan program I need to convert my matrix using as.matrix() base class in order for the function to work.

Unfortunately, my matrix is very sparse so my data-set goes from 10 Mb to 2 GB when I call as.matrix, and my R session crashes due to memory error.

My question is: can STAN use the SparseMatrix class from R in its computation? If so, how would I go about using this?

Reproducible Steps:
Current Output:

If applicable, any relevant output from RStan.

Expected Output:

If applicable, the output you expected from RStan.

RStan Version:

2.21.1

R Version:

4.02

Operating System:

Your operating system (e.g., Ubuntu 20.04

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 with R's Matrix sparse-matrix class and the as.matrix() conversion described in the report; confirm how an RStan program currently receives matrix data. Done means the requested sparse input path is either supported without densifying the dataset or its limitation and usage are clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.