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 |
The function gof_ks
performs Kolmogorov-Smirnov goodness-of-fit
test for the Vasicek distribution
gof_ks(x, Rho, P)
gof_ks(x, Rho, P)
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 |
A list with statistical test result, including ks stat and p-value.
x <- vsk_rvs(100, Rho = 0.2, P = 0.1) gof_ks(x, Rho = 0.2, P = 0.1)
x <- vsk_rvs(100, Rho = 0.2, P = 0.1) gof_ks(x, Rho = 0.2, P = 0.1)
The function vsk_cdf
calculates the cumulative distribution
function of Vasicek.
vsk_cdf(x, Rho, P)
vsk_cdf(x, Rho, P)
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 |
A numeric vector with the corresponding cdf.
vsk_cdf(c(0.278837772815679, 0.5217229060260343), Rho = 0.2, P = 0.3) # [1] 0.5 0.9
vsk_cdf(c(0.278837772815679, 0.5217229060260343), Rho = 0.2, P = 0.3) # [1] 0.5 0.9
The function vsk_mle
estimates parameters in the Vasicek
distribution by using direct moment matching.
vsk_dmm(x)
vsk_dmm(x)
x |
A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution |
A list with Vasicek parameters, namely Rho and P.
vsk_dmm(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2135844 # $P # [1] 0.1025469
vsk_dmm(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2135844 # $P # [1] 0.1025469
The function vsk_imm
estimates parameters in the Vasicek
distribution by using indirect moment matching.
vsk_imm(x)
vsk_imm(x)
x |
A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution |
A list with Vasicek parameters, namely Rho and P.
vsk_imm(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2110422 # $P # [1] 0.1024877
vsk_imm(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2110422 # $P # [1] 0.1024877
The function vsk_mle
estimates parameters in the Vasicek
distribution by using maximum likelihood estimator.
vsk_mle(x)
vsk_mle(x)
x |
A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution |
A list with Vasicek parameters, namely Rho and P.
vsk_mle(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2110976 # $P # [1] 0.1025469
vsk_mle(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.2110976 # $P # [1] 0.1025469
The function vsk_pdf
calculates the probability density
function of Vasicek.
vsk_pdf(x, Rho, P)
vsk_pdf(x, Rho, P)
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 |
A numeric vector with the corresponding pdf.
vsk_pdf(c(0.01, 0.02), Rho = 0.2, P = 0.3) # [1] 0.07019659 0.22207564
vsk_pdf(c(0.01, 0.02), Rho = 0.2, P = 0.3) # [1] 0.07019659 0.22207564
The function vsk_ppf
calculates the percentile point
function of Vasicek.
vsk_ppf(Alpha, Rho, P)
vsk_ppf(Alpha, Rho, P)
Alpha |
A numeric vector of probabilities |
Rho |
The Rho parameter in the Vasicek distribution |
P |
The P parameter in the Vasicek distribution |
A numeric vector with the corresponding ppf.
vsk_ppf(c(0.5, 0.9), Rho = 0.2, P = 0.3) # [1] 0.2788378 0.5217229
vsk_ppf(c(0.5, 0.9), Rho = 0.2, P = 0.3) # [1] 0.2788378 0.5217229
The function vsk_qbe
estimates parameters in the Vasicek
distribution by using quantile-based estimator. It is not recommended
for small sample size.
vsk_qbe(x)
vsk_qbe(x)
x |
A numeric vector in the (0, 1) interval that is supposed to follow the Vasicek distribution |
A list with Vasicek parameters, namely Rho and P.
vsk_qbe(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.1941091 # $P # [1] 0.1019701
vsk_qbe(vsk_rvs(1000, Rho = 0.2, P = 0.1)) # $Rho # [1] 0.1941091 # $P # [1] 0.1019701
The function vsk_Rho
estimates Rho parameter in the Vasicek
distribution by using maximum likelihood estimator, assuming the
known P parameter.
vsk_Rho(x, p)
vsk_Rho(x, p)
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. |
A scalar representing the Rho parameter in the Vasicek distribution.
x <- vsk_rvs(1000, Rho = 0.2, P = 0.1) p <- rep(mean(x), length(x)) vsk_Rho(x, p) # 0.2110976
x <- vsk_rvs(1000, Rho = 0.2, P = 0.1) p <- rep(mean(x), length(x)) vsk_Rho(x, p) # 0.2110976
The function vsk_rvs
generates random numbers for the Vasicek
distribution.
vsk_rvs(n, Rho, P, seed = 1)
vsk_rvs(n, Rho, P, seed = 1)
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. |
A list of random number that follows the Vasicek distribution.
vsk_rvs(10, Rho = 0.2, P = 0.1)
vsk_rvs(10, Rho = 0.2, P = 0.1)