Improve support (or documentation) for weighted draws

Aperta
#184 16 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r
Ambito
data

Direzione di ricerca

Inizia dagli entry point weight_draws(), resample_draws() e as_draws_rvars(), quindi esamina come gli oggetti draws_rvars gestiscono i draws ponderati e le operazioni di riepilogo. Il lavoro è completato quando il supporto per i draws_rvars ponderati funziona, incluso mean(), oppure quando la documentazione indica chiaramente la limitazione supportata e il percorso di conversione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation

?weight_draws says Add weights to draws objects, with one weight per draw, for use in subsequent weighting operations. Currently the only supported subsequent operation is resample_draws(), but the documentation doesn't make it clear. Ideally rvars support would be extended to support weighted draws, but if that is infeasible, the documentation should be clarified.

Example:

> x = rvar_rng(rnorm, 4, mean = 1:4, sd = 2)
> w=runif(4000)

weight_draws() is not defined for draws_rvars:

> xw = weight_draws(x, w, log=FALSE)
Error in UseMethod("weight_draws") : 
  no applicable method for 'weight_draws' applied to an object of class "c('rvar', 'vctrs_vctr', 'list')"

There is no error if weighted draws_df is converted to draws_rvars:

> xw = as_draws_rvars(weight_draws(as_draws_df(x), w, log=FALSE))

The default print method gives the unweighted result

> xw
# A draws_rvars: 4000 iterations, 1 chains, and 1 variables
$x: rvar<4000>[4] mean ± sd:
[1] 0.96 ± 2  1.95 ± 2  3.02 ± 2  4.05 ± 2 

and mean fails

> mean(xw)
[1] NA
Warning message:
In mean.default(xw) : argument is not numeric or logical: returning NA
Lingua principale
R
Stelle
172
Fork
27
Merge medio
5g 12h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stan-dev/posterior

Tutte le issue di stan-dev/posterior

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.