Cannot request draws from the posterior for one parameter with extract.samples()
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
Start from the extract.samples() function in the rethinking package, which accepts a pars argument but returns draws for every parameter. Run the reproduction script in the issue, where extract.samples(mymodel, pars="b2") should return only b2 draws. Done means the pars argument filters the output and the returned list contains only the requested parameters.
Written by the indexing model from the issue text.
Description
I cannot seem to limit the parameters in extract.samples() with the pars= argument. I don't actually see this argument used in Statistical Rethinking, so maybe it does not work yet? However, I'm trying to reduce the size of the list of draws for a large model. This toy example just illustrates what I am seeing:
library(rethinking)
x <- rnorm(100, 0, 1)
b <- rbern(100)
c <- rnorm(100, 2, .1)
sigma <- rnorm(100, 0, .2)
y <- x + bc + sigma
mylist <- list(y=y, x=x, tx=b)
mymodel <- ulam(
alist(
y ~ dnorm(mu, sigma),
mu <- a0 + b1x + b2*tx,
a0 ~ dnorm(0,3),
b1 ~ dnorm(0,3),
b2 ~ dnorm(0,3),
sigma ~ dexp(1)
), data=mylist, cores=3, chains=3, iter=3000
)
precis(mymodel)
fit <- extract.samples(mymodel, pars="b2") # Still gives posterior for all parameters
- Dominant language
- R
- Stars
- 2.4k
- Forks
- 632
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rmcelreath/rethinking
-
Typo: p.381Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
rmcelreath/rethinking#482 ·
-
Typo: p.302Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
rmcelreath/rethinking#475 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
rmcelreath/rethinking#474 ·
-
Comma splice: p.557Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
rmcelreath/rethinking#471 ·
-
Typo: p.555Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
rmcelreath/rethinking#470 ·
All issues in rmcelreath/rethinking
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
automation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
merliseclyde/BAS#118 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
1.7
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pharmaverse/admiral#3235 ·
Maintainers usually reply within 2 days