mcmcpairs <- function( posterior , n=500 , cex=0.7 , pch=16 , adj=1 , ...) { panel.dens <- function(x, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h <- density(x,adj=adj) y <- h$y y <- y/max(y) abline( v=0 , col="gray" , lwd=0.5 ) lines( h$x , y ) } panel.2d <- function( x , y , ... ) { i <- sample( 1:length(x) , size=n ) abline( v=0 , col="gray" , lwd=0.5 ) abline( h=0 , col="gray" , lwd=0.5 ) dcols <- densCols( x[i] , y[i] ) points( x[i] , y[i] , col=dcols , ... ) } panel.cor <- function( x , y , ... ) { k <- cor( x , y ) cx <- sum(range(x))/2 cy <- sum(range(y))/2 text( cx , cy , round(k,2) , cex=2*exp(abs(k))/exp(1) ) } pairs( posterior , cex=cex , pch=pch , upper.panel=panel.2d , lower.panel=panel.cor , diag.panel=panel.dens , ... )}Is there a way to have it plot all of the chains above
the diagonal? I just want the full set of correlation plots.
I'd prefer below the diagonal to just be empty.
When I try:
|
> pairs(fit, pars=c("k1","k2","alpha21","alpha12","gamma"), condition = list(1:4,1:4))
|
I get:
|
Error in if (!missing(bandwidth) && min(bandwidth) <= 0) stop("'bandwidth' must be strictly positive") :
missing value where TRUE/FALSE needed
It works fine when I split the chains in the list, as in
condition = list(1:2, 3:4)
I also thought I'd give this example a spin:
|
> pairs(fit, pars=c("k1","k2","alpha21","alpha12","gamma"), condition = lp > median(lp))
|
but it says:
|
Error in pairs.stanfit(fit, pars = c("k1", "k2", "alpha21", "alpha12", :
object 'lp' not found
|
I couldn't get any form of the comparison working, using lp__ or the other variables,
so I'm probably missing something fundamental about R and this example.