hanaml.mcmc is a R wrapper for SAP HANA PAL Markov chain Monte Carlo algorithm.

hanaml.mcmc(
  conn,
  distribution,
  location = NULL,
  scale = NULL,
  shape = NULL,
  dof = NULL,
  chain.iter = NULL,
  random.state = NULL,
  init.radius = NULL,
  adapt = NULL,
  warmup = NULL,
  thin = NULL,
  adapt.gamma = NULL,
  adapt.delta = NULL,
  adapt.kappa = NULL,
  adapt.offset = NULL,
  adapt.init.buffer = NULL,
  adapt.term.buffer = NULL,
  adapt.window = NULL,
  stepsize = NULL,
  stepsize.jitter = NULL,
  max.depth = NULL,
  alpha = NULL,
  beta = NULL,
  lambda = NULL,
  mu = NULL,
  nu = NULL,
  omega = NULL,
  sigma = NULL,
  xi = NULL,
  L = NULL,
  y.min = NULL
)

Arguments

conn

ConnectionContext
SAP HANA Database connection object.

distribution

character
Specifies the name of distribution. Valid options include: 'normal', 'skew.normal', 'student.t', 'cauchy', 'laplace', 'logistic', 'gumbel', 'exponential', 'chi.square'.
The valid parameters for each distribution are shown as follows:

  • 1. "normal": mu(location), sigma(scale).

  • 2. "skew.normal": mu(location), omega(scale), alpha(shape).

  • 3. "student.t": nu(dof), mu(location), sigma(scale).

  • 4. "cauchy": mu(location), sigma(scale).

  • 5. "laplace": mu(location), sigma(scale).

  • 6. "logistic": mu(location), sigma(scale).

  • 7. "gumbel": mu(location), beta(scale).

  • 8. "exponential": beta(inverse-scale).

  • 9. "chi.square": nu(dof).

  • 10. "invchi.square": nu.

  • 11. "gamma": alpha, beta.

  • 12. "weibull": alpha, sigma.

  • 13. "frechet": alpha, sigma.

  • 14. "rayleigh": sigma.

  • 15. "multinormal": mu, sigma.

  • 16. "multinormalprec": mu, omega.

  • 17. "multinormalcholesky": mu, L.

  • 18. "multistudent.t": nu, mu, sigma.

  • 19. "dirichlet": alpha.

  • 20. "beta": alpha, beta.

  • 21. "invgamma": alpha, beta.

  • 22. "lognormal": mu, sigma.

  • 23. "pareto": y.min, alpha.

  • 24. "lomax": lambda, alpha.

location

double, optional(deprecated)
Specifies the location parameter for a distribution. Valid when distribution is set to one of the following values: "normal", "skew.normal", "student.t", "cauchy", "laplace", "logistic".
Defaults to 0.
Deprecated, please use mu.

scale

double, optional(deprecated)
Specifies the scale parameter for a distribution. Valid only when distribution is set to one of the following values: "normal", "skew.normal", "student.t", "cauchy", "laplace", "logistic", "exponential".
Defaults to 1.0.
Deprecated, please use sigma or beta(whichever depends on the type of distributions).

shape

double, optional(deprecated)
Specifies the shape parameter for a distribution. Valid only when distribution is set to 'skew.normal'.
Defaults to 1.0.
Deprecated, please use alpha.

dof

double, optional(deprecated)
Specifies the degree of freedom of a distribution. Valid only when distribution is "student.t" or "chi.square".
Defaults to 1.0.
Deprecated, please use nu.

chain.iter

integer, optional
Specifies number of iterations for each Markov chain including warmup.
Defaults to 2000.

random.state

integer, optional
Specifies the seed used to initialize the random number generator, where 0 means current system time as seed, while other values are simply seed values.
Defaults to 0.

init.radius

double, optional
Specifies the radius to initialize the process.
Defaults to 2.0.

adapt

logical, optional
Specifies whether or not to use adaption.
Defaults to TRUE.

warmup

integer, optional
Specifies the number of warm-up iterations. Defaults to half of chain.iter.

thin

integer, optional
Specifies the period for saving samples.
Defaults to 1.

adapt.gamma

double, optional
Specifies the regularization scale for adaption, must be positive. Invalid when adapt is FALSE.
Defaults to 0.05.

adapt.delta

double, optional
Specifies the target Metropolis acceptance rate, must be restricted between 0 and 1(inclusive of both limits). Only valid when adapt is TRUE.
Defaults to 0.8.

adapt.kappa

double, optional
Specifies the relaxation exponent, must be positive. Only valid when adapt is TRUE.
Defaults to 0.75.

adapt.offset

double, optional
Specifies the adaption iteration offset, must be positive. Only valid when adapt is TRUE.
Defaults to 10.0.

adapt.init.buffer

integer, optional
Specifies the width of initial fast adaption interval. Only valid when adapt is TRUE.
Defaults to 75.

adapt.term.buffer

integer, optional
Specifies the width of terminal(final) fast adaption interval. Only valid when adapt is TRUE.
Defaults to 50.

adapt.window

integer, optional
Specifies the initial width of slow adaption interval. Only valid when adapt is TRUE.
Defaults to 25.

stepsize

double, optional
Specifies the value for discretizing the time interval.
Defaults to 1.0.

stepsize.jitter

double, optional
Specifies the uniform random jitter of step-size.
Defaults to 0.

max.depth

integer, optional
Specifies the maximum tree depth.
Defaults to 10.

alpha

numeric, optional
Specifies the value of parameter alpha in a distribution.
Mandatory and valid only if the corresponding distribution contains alpha as a parameter.

beta

numeric, optional
Specifies the value of parameter beta in a distribution.
Mandatory and valid only if the corresponding distribution contains beta as a parameter.

lambda

numeric, optional
Specifies the value of parameter lambda in a distribution.
Mandatory and valid only if the corresponding distribution contains lambda as a parameter.

mu

numeric, optional Numerical value or vector that represents the mean value of a distribution.
Mandatory and valid if the corresponding distribution contains mu as a parameter.

nu

numeric, optional
Specifies the value of parameter nu(often representing the degree of freedom) in a distribution.
Mandatory and valid only if the corresponding distribution contains nu as a parameter.

omega

numeric, optional
Numerical value or vector for parameter omega in a distribution.
Mandatory and valid only if the corresponding distribution contains omega as a parameter.

sigma

numeric, optional
Numerical value or vector for parameter sigma in a distribution.
Mandatory and valid only if the corresponding distribution contains omega as a parameter.

xi

numeric, optional
Specifies the value of parameter xi(i.e. the mean) in skew-normal distribution.
Mandatory and valid only if distribution is "skew.normal".

L

numeric, optional
A numeric vector that specifies lower triangular matrix in the cholesky decomposition of the covariance matrix in multi-normal distribution.
Mandatory only if distribution is "multinormalcholesky".

y.min

numeric, optional
Specifies the value of parameter y.min in Pareto distribution.
Mandatory and valid only if distribution is "pareto".

Value

DataFrame
Samples of the specified distribution generated from Markov Chain Monte-Carlo process.

Details

Given a distribution, this function generates samples of the distribution using Markov chain Monte Carlo simulation.

Examples

The following line of code shows how to generate MCMC samples from student.t distribution with specified distribution parameters:


> res <- hanaml.mcmc(conn, distribution = "student.t",
                     location = 0, dof = 1,
                     chain.iter = 50, thin = 10,
                     init.radius = 0)
> res$Collect()
   ID   SAMPLES
1   0 -1.728452
2   1  1.575337
3   2  1.185957
4   3  4.913828
5   4  0.220282
6   5 -5.588809