Dealing with chains of different length

オープン
#334 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
r
領域
data

調査の方向性

repair_draws() によってチェーン長が不均一になった後の niterations と、draws_df、draws_matrix、draws_list、draws_array の変換エントリーポイントを比較することから始めます。提案されている対処法として merge_chains を確認し、情報量のある警告またはエラーをどこで生成すべきかを判断します。チェーン長が不均一な場合に一貫して処理され、必要に応じて draws_array がユーザーを merge_chains に誘導できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I suppose there is an implicit expectation that all chains are the same length, but different lengths can occur when doing filtering with e.g. dplyr. I think the recommended workflow should likely be to merge chains before doing this kind of filtering, but I guess that can't be enforced.

Currently, different draws formats handle chains of varying length differently in how they calculate niterations (even after repairing). And draws_array does not allow different length chains at all -> I think the error message could point to merge_chains as a solution.

Consider filtering a draws_df based on the value of some variable (below dplyr is used to do so, but it could be done in base R syntax). This can end up with a draws_df that has different length chains.

library(posterior)
library(dplyr)
fdraws <- example_draws() |>
as_draws_df() |>
dplyr::filter(`mu` > 0) |>
repair_draws()

niterations(fdraws)
## [1] 94

niterations(as_draws_matrix(fdraws))
## [1] 89.5

niterations(as_draws_list(fdraws))
## [1] 90

as_draws_array(fdraws)
## Error in abind::abind(x, along = 3L) : 
##   arg 'X2' has dims=86, 10, 1; but need dims=90, 10, X

Should there be a message/warning given when a draws object has different length chains that suggests merge_chains?

主要言語
R
スター
172
フォーク
27
平均マージ
5日 12時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stan-dev/posterior のほかの issue

stan-dev/posterior の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。