I am running model 10.3stan in McEalreath’s book Statistical rethinking.
library(rethinking)
data(chimpanzees)
d <- chimpanzees
m10.3 <- map(
alist(
pulled_left ~ dbinom( 1 , p ) ,
logit(p) <- a + (bp + bpC*condition)*prosoc_left ,
a ~ dnorm(0,10) ,
bp ~ dnorm(0,10) ,
bpC ~ dnorm(0,10)
) ,
data=d )
d2 <- d
d2$recipient <- NULL
# re-use map fit to get the formula
m10.3stan <- map2stan( m10.3 , data=d2 , iter=1e4 , warmup=1000 )
precis(m10.3stan) ### this works
# code 10.13
pairs(m10.3stan) ## THIS DOES NOT WORK
error:Error in linbin2D(x, gpoints1, gpoints2) : object 'F_lbtwod' not found
I haven’t tried it myself but if it’s an S4 class then I would try @ instead of $.
Also, if your model happens to have a lot of parameters I would specify a small subset of them when calling pairs or else the plot can take a long time to render and also be hard to read.
Looks like the error @aaronjg mentioned above. Can you successfully use the pairs method with a model fit directly using rstan (rather than rstan via rethinking)? You could test it using one of the example models:
library("rstan")
fit <- stan_demo("eight_schools") # you may be prompted to allow it to download example models
pairs(fit, pars = c("theta[1]", "theta[2]", "lp__"))
This seems to be an old topic, but for those who struggle with the same problem: Reinstalling the KernSmooth package from CRAN solved the problem for me.