link() not handling id variable values not in original data
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
Start by running the reproducible example in the issue: fit a small ulam() model with an index variable (store_id), then call link() on new data with store_id values 1, 2 and 0 to see which ones fail. The payload does not name the source files involved, so locate link() and its index handling yourself. Done means either link() handles unseen index values as the documentation describes, or the error and documentation are changed to say clearly what is required. Expect design questions from the maintainer, and check the thread first.
Written by the indexing model from the issue text.
Description
Howdy,
I don't know if this is a bug or if the function documentation is out of date, but link() no longer will handle an indexing variable set to 0 or missing (for ulam output, at least) and throws an error instead. Here's an example:
library(rethinking)
tib<-tibble(store_id=c(1,1,1,2,2,2),
y=c(0,1,2,0,2,4),
x=c(0,1,2,0,1,2))
ulam_obj<-ulam(
alist(y~normal(product,.0000001),
product<- (bx[store_id] +b )*x,
bx[store_id] ~ normal(0,1),
b ~ normal(1.5,.00001)
),
data=tib,
chains=1,sample=T,iter=50
)
new_tib1<-tibble(store_id=c(1,1),x=c(3,4))
new_tib2<-tibble(store_id=c(2,2),x=c(3,4))
new_tib0<-tibble(store_id=c(0,0),x=c(3,4))
link(ulam_obj,new_tib1)
link(ulam_obj,new_tib2)
#this one errors:
link(ulam_obj,new_tib0)
#as does
new_tib<-tibble(x=c(3,4))
link(ulam_obj,new_tib)
If you have the time, I'd love a pointer or hint or suggestion towards a workaround. The inner workings of link() are mysterious to this uninitiated fellow. Many thanks, again, for the work you've put in to the package and into educating so many of us.
- 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