Input and output variables of a Stan program — model-method-variables • cmdstanr
Description: The $variables() method of a CmdStanModel object returns a list, each element representing a Stan model block: data, parameters, transformed_parameters and generated_quantities. Each element contains a list of variables, with each variables represented as a list with infromation on its scalar type (real or int) and number of dimensions. transformed data is not included, as variables in that block are not part of the model's input or output.

# Input and output variables of a Stan program

Source: `R/model.R`
`model-method-variables.Rd`

The `$variables()` method of a `CmdStanModel` object returns a list, each element representing a Stan model block: `data`, `parameters`, `transformed_parameters` and `generated_quantities`.

Each element contains a list of variables, with each variables represented as a list with infromation on its scalar type (`real` or `int`) and number of dimensions.

`transformed data` is not included, as variables in that block are not part of the model's input or output.

    variables()

## Value

The `$variables()` returns a list with information on input and output variables for each of the Stan model blocks.

## See also

Other CmdStanModel methods: `model-method-check_syntax`, `model-method-compile`, `model-method-diagnose`, `model-method-expose_functions`, `model-method-format`, `model-method-generate-quantities`, `model-method-optimize`, `model-method-sample_mpi`, `model-method-sample`, `model-method-variational`

## Examples

    # \dontrun{
    file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")

    # create a `CmdStanModel` object, compiling the model is not required
    mod <- cmdstan_model(file, compile = FALSE)

    mod$variables()
    #> $parameters
    #> $parameters$theta
    #> $parameters$theta$type
    #> [1] "real"
    #>
    #> $parameters$theta$dimensions
    #> [1] 0
    #>
    #>
    #>
    #> $included_files
    #> list()
    #>
    #> $data
    #> $data$N
    #> $data$N$type
    #> [1] "int"
    #>
    #> $data$N$dimensions
    #> [1] 0
    #>
    #>
    #> $data$y
    #> $data$y$type
    #> [1] "int"
    #>
    #> $data$y$dimensions
    #> [1] 1
    #>
    #>
    #>
    #> $transformed_parameters
    #> named list()
    #>
    #> $generated_quantities
    #> named list()
    #>

    # }