Last data update: 2014.03.03

R: Check Parameters of the Normal Laplace Distribution
nlCheckParsR Documentation

Check Parameters of the Normal Laplace Distribution

Description

Given a set of parameters for the normal Laplace distribution, the functions checks the validity of each parameter and if they and if they correspond to the boundary cases.

Usage

nlCheckPars(param)

Arguments

param

Numeric. Parameter values for the normal Laplace distribution.

Details

The vector param takes the form c(mu, sigma, alpha, beta).

If any of sigma, alpha or beta is negative or NA, an error is returned.

Author(s)

David Scott d.scott@auckland.ac.nz, Simon Potter

References

William J. Reed. (2006) The Normal-Laplace Distribution and Its Relatives. In Advances in Distribution Theory, Order Statistics and Inference, pp. 61–74. Birkh<c3><a4>user, Boston.

Examples

## Correct parameters
nlCheckPars(c(0, 1.5, 1, 2))
nlCheckPars(c(3, 1, 1.5, 2))

## Incorrect parameters, each error providing a different error message
nlCheckPars(c(2, -1, 1, 1))          # invalid sigma
nlCheckPars(c(2, 1, -1, 2))          # invalid alpha
nlCheckPars(c(0, 1, 2, -1))          # invalid beta
nlCheckPars(c(0, -0.01, -0.1, 1))    # sigma and alpha incorrect
nlCheckPars(c(2, -0.5, 1, -0.2))     # sigma and beta incorrect
nlCheckPars(c(1, 1, -0.2, -1))       # alpha and beta incorrect
nlCheckPars(c(0, -0.1, -0.2, -0.3))  # all three parameters erroneous
nlCheckPars(c(0.5, NA, 1, 1))        # NA introduced
nlCheckPars(c(-1, 1, 1))             # incorrect number of parameters

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(NormalLaplace)
Loading required package: DistributionUtils
Loading required package: RUnit
Loading required package: GeneralizedHyperbolic
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/NormalLaplace/nlCheckPars.Rd_%03d_medium.png", width=480, height=480)
> ### Name: nlCheckPars
> ### Title: Check Parameters of the Normal Laplace Distribution
> ### Aliases: nlCheckPars
> ### Keywords: distribution
> 
> ### ** Examples
> 
> ## Correct parameters
> nlCheckPars(c(0, 1.5, 1, 2))
$case
[1] ""

$errMessage
[1] ""

> nlCheckPars(c(3, 1, 1.5, 2))
$case
[1] ""

$errMessage
[1] ""

> 
> ## Incorrect parameters, each error providing a different error message
> nlCheckPars(c(2, -1, 1, 1))          # invalid sigma
$case
[1] "error"

$errMessage
[1] "sigma must be non-negative"

> nlCheckPars(c(2, 1, -1, 2))          # invalid alpha
$case
[1] "error"

$errMessage
[1] "alpha must be non-negative"

> nlCheckPars(c(0, 1, 2, -1))          # invalid beta
$case
[1] "error"

$errMessage
[1] "beta must be non-negative"

> nlCheckPars(c(0, -0.01, -0.1, 1))    # sigma and alpha incorrect
$case
[1] "error"

$errMessage
[1] "sigma and alpha must be non-negative"

> nlCheckPars(c(2, -0.5, 1, -0.2))     # sigma and beta incorrect
$case
[1] "error"

$errMessage
[1] "sigma and beta must be non-negative"

> nlCheckPars(c(1, 1, -0.2, -1))       # alpha and beta incorrect
$case
[1] "error"

$errMessage
[1] "alpha and beta must be non-negative"

> nlCheckPars(c(0, -0.1, -0.2, -0.3))  # all three parameters erroneous
$case
[1] "error"

$errMessage
[1] "sigma, alpha and beta must be non-negative"

> nlCheckPars(c(0.5, NA, 1, 1))        # NA introduced
$case
[1] "error"

$errMessage
[1] "NAs encountered in parameter vector"

> nlCheckPars(c(-1, 1, 1))             # incorrect number of parameters
$case
[1] "error"

$errMessage
[1] "param vector must contain 4 values"

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>