ulam fits giving odd errors

Open
#430 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

The failure is Error in pred[[j]][s, ] : subscript out of bounds, raised when postcheck() runs on a model fitted by ulam() with the reedfrogs data. Start by running the reproduction snippet and checking the alist model, especially the logit(prob) <- p line, which uses <- where the other lines use ~. Done means the snippet fits and postcheck() shows every row of reedfrogs, not a single point.

Written by the indexing model from the issue text.

Description

bug

I'm working with ulam a bit to show mixed models in a few context. This example:

library(rethinking)
data(reedfrogs)

mod_fullpool <- alist(
  
  #likelihood
  surv ~ dbinom(density, prob),
  
  #Data Generating Process
  logit(prob) <- p,
  
  #Priors
  p ~ dnorm(0,10)
)

fit_fullpool <- ulam(mod_fullpool, data=reedfrogs)
postcheck(fit_fullpool)

however, gives an odd error

Error in pred[[j]][s, ] : subscript out of bounds

I can up the number of chains and then postcheck it. However, I only get a single point, instead of looking at all rows of the reedfrogs data.

Here's my relevant sessioninfo

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] digest_0.6.35   rethinking_2.40 posterior_1.5.0 cmdstanr_0.7.1 
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rmcelreath/rethinking

All issues in rmcelreath/rethinking

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.