Learn R Programming

shinystan (version 2.0.0)

as.shinystan: Create and test shinystan objects

Description

Create and test shinystan objects

Usage

as.shinystan(X, ...)

is.shinystan(object)

Arguments

Value

For as.shinystan an object of class shinystan that can be used with launch_shinystan. For is.shinystan a logical value indicating whether the tested object is a shinystan object.

Details

If X is a stanfit object then no additional arguments should be specified in ... (they are taken automatically from the stanfit object). If X is not a stanfit object then the following arguments can be specified but are not required:

[object Object],[object Object],[object Object],[object Object]

See Also

launch_shinystan, launch_shinystan_demo

Examples

Run this code
#################
### 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