Package 'vasicek'

Title: Miscellaneous Functions for Vasicek Distribution
Description: Provide a collection of miscellaneous R functions related to the Vasicek distribution with the intent to make the lives of risk modelers easier.
Authors: WenSui Liu
Maintainer: WenSui Liu <[email protected]>
License: GPL (>= 2)
Version: 0.0.3
Built: 2025-01-31 03:07:50 UTC
Source: https://github.com/cran/vasicek

Help Index


Kolmogorov-Smirnov goodness-of-fit test for the Vasicek distribution

Description

The function gof_ks performs Kolmogorov-Smirnov goodness-of-fit test for the Vasicek distribution

Usage

gof_ks(x, Rho, P)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Rho

The Rho parameter in the Vasicek distribution

P

The P parameter in the Vasicek distribution

Value

A list with statistical test result, including ks stat and p-value.

Examples

x <- vsk_rvs(100, Rho = 0.2, P = 0.1)
gof_ks(x, Rho = 0.2, P = 0.1)

Calculating the cumulative distribution function of Vasicek

Description

The function vsk_cdf calculates the cumulative distribution function of Vasicek.

Usage

vsk_cdf(x, Rho, P)

Arguments

x

A numeric vector in the [0, 1] interval that is supposed to follow the Vasicek distribution

Rho

The Rho parameter in the Vasicek distribution

P

The P parameter in the Vasicek distribution

Value

A numeric vector with the corresponding cdf.

Examples

vsk_cdf(c(0.278837772815679, 0.5217229060260343), Rho = 0.2, P = 0.3)
# [1] 0.5 0.9

Estimating Vasicek parameters by using direct moment matching

Description

The function vsk_mle estimates parameters in the Vasicek distribution by using direct moment matching.

Usage

vsk_dmm(x)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Value

A list with Vasicek parameters, namely Rho and P.

Examples

vsk_dmm(vsk_rvs(1000, Rho = 0.2, P = 0.1))
# $Rho
# [1] 0.2135844
# $P
# [1] 0.1025469

Estimating Vasicek parameters by using indirect moment matching

Description

The function vsk_imm estimates parameters in the Vasicek distribution by using indirect moment matching.

Usage

vsk_imm(x)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Value

A list with Vasicek parameters, namely Rho and P.

Examples

vsk_imm(vsk_rvs(1000, Rho = 0.2, P = 0.1))
# $Rho
# [1] 0.2110422
# $P
# [1] 0.1024877

Estimating Vasicek parameters by using maximum likelihood estimator

Description

The function vsk_mle estimates parameters in the Vasicek distribution by using maximum likelihood estimator.

Usage

vsk_mle(x)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Value

A list with Vasicek parameters, namely Rho and P.

Examples

vsk_mle(vsk_rvs(1000, Rho = 0.2, P = 0.1))
# $Rho
# [1] 0.2110976
# $P
# [1] 0.1025469

Calculating the probability density function of Vasicek

Description

The function vsk_pdf calculates the probability density function of Vasicek.

Usage

vsk_pdf(x, Rho, P)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Rho

The Rho parameter in the Vasicek distribution

P

The P parameter in the Vasicek distribution

Value

A numeric vector with the corresponding pdf.

Examples

vsk_pdf(c(0.01, 0.02), Rho = 0.2, P = 0.3)
# [1] 0.07019659 0.22207564

Calculating the percentile point function of Vasicek

Description

The function vsk_ppf calculates the percentile point function of Vasicek.

Usage

vsk_ppf(Alpha, Rho, P)

Arguments

Alpha

A numeric vector of probabilities

Rho

The Rho parameter in the Vasicek distribution

P

The P parameter in the Vasicek distribution

Value

A numeric vector with the corresponding ppf.

Examples

vsk_ppf(c(0.5, 0.9), Rho = 0.2, P = 0.3)
# [1] 0.2788378 0.5217229

Estimating Vasicek parameters by using quantile-based estimator

Description

The function vsk_qbe estimates parameters in the Vasicek distribution by using quantile-based estimator. It is not recommended for small sample size.

Usage

vsk_qbe(x)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

Value

A list with Vasicek parameters, namely Rho and P.

Examples

vsk_qbe(vsk_rvs(1000, Rho = 0.2, P = 0.1))
# $Rho
# [1] 0.1941091
# $P
# [1] 0.1019701

Estimating Vasicek Rho parameter by assuming the know P parameter

Description

The function vsk_Rho estimates Rho parameter in the Vasicek distribution by using maximum likelihood estimator, assuming the known P parameter.

Usage

vsk_Rho(x, p)

Arguments

x

A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution

p

A numeric vector in the (0, 1) interval. p has the same length as x. Each value of p can be a constant or varying.

Value

A scalar representing the Rho parameter in the Vasicek distribution.

Examples

x <- vsk_rvs(1000, Rho = 0.2, P = 0.1)
p <- rep(mean(x), length(x))
vsk_Rho(x, p)
# 0.2110976

Generating random numbers for the Vasicek distribution

Description

The function vsk_rvs generates random numbers for the Vasicek distribution.

Usage

vsk_rvs(n, Rho, P, seed = 1)

Arguments

n

An integer for the number of observations.

Rho

The Rho parameter in the Vasicek distribution. It is in the range of (0, 1).

P

The P parameter in the Vasicek distribution. It is in the range of (0, 1).

seed

An integer that is used as the seed value to generate random numbers.

Value

A list of random number that follows the Vasicek distribution.

Examples

vsk_rvs(10, Rho = 0.2, P = 0.1)