#################
### Example 1 ###
#################
# If X is a mcmc.list, 3D array or list of 2D chains then just do:
X_sso <- as.shinystan(X, ...) # replace ... with optional arguments or omit it
# You can also do the above if X is a stanfit object although it is not
# necessary since launch_shinystan accepts stanfit objects.
##############################################
### Example 2: if X is a list of 2D chains ###
##############################################
# Generate some fake data
chain1 <- cbind(beta1 = rnorm(100), beta2 = rnorm(100), sigma = rexp(100))
chain2 <- cbind(beta1 = rnorm(100), beta2 = rnorm(100), sigma = rexp(100))
X <- list(chain1, chain2)
X_sso <- as.shinystan(X)
# We can also specify some or all of the optional arguments
# note: in order to use param_dims we need to rename 'beta1' and 'beta2'
# to 'beta[1]' and 'beta[2]'
colnames(chain1) <- colnames(chain2) <- c(paste0("beta[",1:2,"]"), "sigma")
X_sso <- as.shinystan(X, param_dims = list(beta = 2, sigma = 0),
model_name = "Example",
burnin = 0)
launch_shinystan(my_shinystan)Run the code above in your browser using DataLab