Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim() from model with missing value imputation breaks with error "function merge_missing not found" #411

Open
andins opened this issue Oct 5, 2023 · 2 comments

Comments

@andins
Copy link

andins commented Oct 5, 2023

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)
@rmcelreath
Copy link
Owner

I don't think this has ever been supported, but maybe it wouldn't be hard to add it. I will make a note of it.

@jebyrnes
Copy link

Second! HA! Trying to write an exercise to look at missing data and how it compares to observed, and indeed, hit this roadblock as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants