Feature request/suggestion - point estimate with interval labels to aid in plotting
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- r
調査の方向性
要求されている点推定値と区間ラベルの動作を確認します。これには、提供された R の例と、平均値、中央値、最頻値、HDI、ETI のサポートされている組み合わせが含まれます。適切な bayesplot のエントリーポイントと API を特定し、フォーマットを検証して、機能が完成した時点を明確にするテストまたは例を定義します。
索引モデルが issue の本文から書いたものです。
説明
I've found it very useful to have easy access to a 'label' providing a chosen point estimate and density interval, which can be added for example to graphs as a means of providing extra, concise information about a parameter or effect that is depicted. E.g., adding label with the median and 95% HDI from the posterior, or whatever other point estimate/interval you choose, in the form: 5.67 [4.33 - 6.01].
The following R code takes a posterior distribution in the form of a vector and returns a summary. You can ignore most of the probably very inelegant coding, but the function inside of this function called 'point.uncertainty' could be a useful place to begin if you think this feature may be useful.
This requires dplyr and hdinterval packages to run.
summarise.me <- function(posterior, name = "summary", interval = .95, p.e = "median", u.e = "hdi") {
hdi.bounds <- hdi(posterior, credMass = interval)
hdi.lower <- hdi.bounds["lower"]
hdi.upper <- hdi.bounds["upper"]
eti.upper <- quantile(posterior, probs = interval + ((1 - interval) / 2) )
eti.lower <- quantile(posterior, probs = (1 - interval) / 2)
mean <- mean(posterior)
median <- median(posterior)
mode <- (density(as.numeric(posterior))
$x[which.max(density(as.numeric(posterior))$y)])
hdi.width <- hdi.upper - hdi.lower
eti.width <- eti.upper - eti.lower
posterior.summary <-
tibble(name = name,
mean = mean,
median = median,
mode = mode,
hdi.lower = hdi.lower,
hdi.upper = hdi.upper,
hdi.width = hdi.width,
eti.lower = eti.lower,
eti.upper = eti.upper,
eti.width = eti.width,
interval = interval)
point.uncertainty <- function(summary, point.estimate = "mean", uncertainty = "hdi") {
if (point.estimate == "mean" & uncertainty == "hdi")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$mean)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.upper)),
"]" ,
sep = "")
} else if (point.estimate == "mode" & uncertainty == "hdi")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$mode)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.upper)),
"]" ,
sep = "")
} else if (point.estimate == "median" & uncertainty == "hdi")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$median)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$hdi.upper)),
"]" ,
sep = "")
} else if (point.estimate == "mean" & uncertainty == "eti")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$mean)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.upper)),
"]" ,
sep = "")
} else if (point.estimate == "mode" & uncertainty == "eti")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$mode)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.upper)),
"]" ,
sep = "")
}else if (point.estimate == "median" & uncertainty == "eti")
{
paste(sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$median)),
" [",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.lower)),
"-",
sub("^(-?)0.", "\\1.", sprintf("%.2f", summary$eti.upper)),
"]" ,
sep = "")
}
}
posterior.summary <- posterior.summary %>%
mutate(label = point.uncertainty(posterior.summary, point.estimate = p.e, uncertainty = u.e))
return(posterior.summary)
}
- 主要言語
- R
- スター
- 442
- フォーク
- 93
- 平均マージ
- 3時間 17分
- マージ済み PR(30日)
- 2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stan-dev/bayesplot のほかの issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
pp_check and rvars オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
documentation
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
stan-dev/bayesplot の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
briandconnelly/airnow#9 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OHDSI/CohortConstructor#774 ·
-
pre-review R TeX Track: 5 (DSAIS)
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
openjournals/joss-reviews#11330 · コメント 7 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100