sim() from model with missing value imputation breaks with error "function merge_missing not found"
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 35/100
Research direction
The error comes from merge_missing being called inside sim() for a model fitted with ulam that has missing-value imputation, so start by checking where merge_missing is defined in the package and whether it is exported or reachable from the sim code path. Reproduce with the m15.5 snippet in the issue and confirm that sim(m15.5) fails. Done means the call succeeds and returns simulated outcomes, with a test covering a model that imputes missing values.
Written by the indexing model from the issue text.
Description
I executed the code for model 15.5 from the book (for doing missing data imputation with primate milk data.
The model runs fine but when I try to sample from posterior distribution using sim() function an exception is raised with error
Error in merge_missing(B_missidx, to_vector(B), B_impute) :
could not find function "merge_missing"
Any idea how to fix it @rmcelreath ?
Full code to reproduce the bug:
library(rethinking)
data(milk)
d <- milk
d$neocortex.prop <- d$neocortex.perc / 100
d$logmass <- log(d$mass)
dat_list <- list(
K = standardize( d$kcal.per.g ),
B = standardize( d$neocortex.prop ),
M = standardize( d$logmass ) )
m15.5 <- ulam(
alist(
K ~ dnorm( mu , sigma ),
mu <- a + bB*B + bM*M,
B ~ dnorm( nu , sigma_B ),
c(a,nu) ~ dnorm( 0 , 0.5 ),
c(bB,bM) ~ dnorm( 0, 0.5 ),
sigma_B ~ dexp( 1 ),
sigma ~ dexp( 1 )
) , data=dat_list , chains=4 , cores=4 )
sim(m15.5)
- 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 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
rmcelreath/rethinking#476 ·
-
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 ·
All issues in rmcelreath/rethinking
Similar issues
-
1.7
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pharmaverse/admiral#3235 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SticsRPacks/CroPlotR#185 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day