Learn R Programming

rstan (version 2.9.0-3)

lookup: Look up the Stan function that corresponds to a Rfunction or name.

Description

This function helps to map between R functions and Stan functions.

Usage

lookup(FUN, ReturnType = character())

Arguments

FUN
A character string naming a Rfunction or a Rfunction for which the (near) equivalent Stan function is sought. If no matching Rfunction is found, FUN is reinterpreted as a regexp and
ReturnType
A character string of positive length naming a valid return type for a Stan function: int, int[], matrix, real, real[,], real[], row_vector, T[]<

Value

  • Ordinarily, a data.frame with rows equal to the number of partial matches and four columns:
    1. StanFunctionCharacter string for the Stan function's name.
    2. ArgumentsCharacter string indicating the arguments to that Stan function.
    3. ReturnTypeCharacter string indicating the return type of that Stan function.
    4. PageInteger indicating the page of the Stan reference manual where that Stan function is defined.
    If FUN = "~", a data.frame with rows equal to the number of sampling statements defined in Stan and three columns:
    1. StanStatementCharacter string indicating the name of the distribution in Stan.
    2. ArgumentsCharacter string indicating the remaining arguments to that Stan function.
    3. PageInteger indicating the page of the Stan reference manual where that Stan sampling statement is defined.
    If there are no matching Stan functions, a character string indicating so is returned.

References

The Stan Development Team Stan Modeling Language User's Guide and Reference Manual. http://mc-stan.org/.

The Stan Development Team CmdStan Interface User's Guide. http://mc-stan.org.

Examples

Run this code
lookup(dnorm)      # Stan equivalents for the normal PDF (in log form)
nrow(lookup("~"))  # number of sampling statements available
lookup("foo")      # fails
lookup("Student")  # succeeds even though there is no such R function
lookup("^poisson") # every Stan function that starts with poisson

Run the code above in your browser using DataLab