| Title: | Goodness-of-Fit Tests for Skew-Normal and Skew-t Models |
|---|---|
| Description: | Provides precomputed-quantile goodness-of-fit tests for skew-normal distributions, parametric-bootstrap tests for skew-normal and skew-t distributions, robust fitting, and graphical diagnostics. Package methods and documentation are described by Li, Xu, and Khang (2026) <https://github.com/Divo-Lee/PBGoF>. |
| Authors: | Hongxiang Li [aut, cre], Chenglin Xu [aut], Tsung Fei Khang [aut] |
| Maintainer: | Hongxiang Li <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.2.0 |
| Built: | 2026-10-13 03:53:31 UTC |
| Source: | https://github.com/cran/PBGoF |
Plots the empirical cumulative distribution function together with the CDF of a fitted skew-normal or skew-t distribution.
cdf.plot.check(data, model = "SN", curve_col = NULL, lwd = 2, main = NULL, xlab = "Values", ylab = "Distribution function", legend = FALSE, ...)cdf.plot.check(data, model = "SN", curve_col = NULL, lwd = 2, main = NULL, xlab = "Values", ylab = "Distribution function", legend = FALSE, ...)
data |
A numeric vector containing finite observations. |
model |
Either |
curve_col |
Color of the fitted CDF. The default is |
lwd |
Line width of the fitted CDF. The ECDF uses |
main |
Main plot title. The default is |
xlab |
Label for the horizontal axis. |
ylab |
Label for the vertical axis. |
legend |
Logical; if |
... |
Additional graphical arguments passed to |
The fitted CDF is overlaid on the ECDF with the standard horizontal reference lines at y = 0 and y = 1.
Invisibly returns a list containing the model, fitted parameters, grid values, fitted CDF values, and ECDF object.
set.seed(123) x <- sn::rsn(200, xi = 0, omega = 1, alpha = 5) cdf.plot.check(x, model = "SN")set.seed(123) x <- sn::rsn(200, xi = 0, omega = 1, alpha = 5) cdf.plot.check(x, model = "SN")
Perform a parametric-bootstrap goodness-of-fit test for either a skew-normal or a skew-t distribution. The fitted model is re-estimated in every bootstrap sample.
para.bootstrap.test( data = NULL, model = c("SN", "ST"), statistic = c("KS", "CvM"), B = 1000L, seed = 103L, verbose = FALSE )para.bootstrap.test( data = NULL, model = c("SN", "ST"), statistic = c("KS", "CvM"), B = 1000L, seed = 103L, verbose = FALSE )
data |
A numeric vector with at least 10 finite observations. |
model |
The fitted model, either |
statistic |
The goodness-of-fit statistic: |
B |
A positive integer giving the number of bootstrap samples. |
seed |
A single integer used to initialize the bootstrap random-number
stream, or |
verbose |
Logical; if |
This function dispatches to the existing model- and statistic-specific
implementations, so the estimation and bootstrap calibration are unchanged.
The legacy functions sn.para.bootstrap.ks.test(),
sn.para.bootstrap.cvm.test(), st.para.bootstrap.ks.test(), and
st.para.bootstrap.cvm.test() remain available for compatibility.
A numeric bootstrap p-value with attributes containing the observed
statistic and bootstrap diagnostics. For the skew-t model, the fitted
parameters are also returned in the fit attribute.
set.seed(123) x_sn <- sn::rsn(100, alpha = 3) para.bootstrap.test(x_sn, model = "SN", statistic = "KS", B = 100) x_st <- sn::rst(100, alpha = 3, nu = 8) para.bootstrap.test(x_st, model = "ST", statistic = "CvM", B = 100)set.seed(123) x_sn <- sn::rsn(100, alpha = 3) para.bootstrap.test(x_sn, model = "SN", statistic = "KS", B = 100) x_st <- sn::rst(100, alpha = 3, nu = 8) para.bootstrap.test(x_st, model = "ST", statistic = "CvM", B = 100)
Computes a skew-normal goodness-of-fit statistic and obtains an approximate p-value from a precomputed 100,000-replicate quantile table.
PBGoF_ks_test(data, ks_table = NULL) PBGoF_cvm_test(data, cvm_table = NULL)PBGoF_ks_test(data, ks_table = NULL) PBGoF_cvm_test(data, cvm_table = NULL)
data |
A numeric vector whose length is at least the smallest sample size represented in the table. |
ks_table, cvm_table
|
Optional custom quantile tables. If |
The fitted absolute CP skewness is rounded to two decimal places and truncated
to [0.01, 0.99]. P-values are conservative step-function approximations
between 0.01 and 0.99. No interpolation is performed.
If the fitted gamma1 is negative, table lookup uses
abs(gamma1). Reflection of a skew-normal variable changes the signs of
the DP shape parameter and CP skewness, but the null distributions of the EDF
statistics are invariant to this sign change (Mateu-Figueras et al., 2007).
The bundled tables therefore require only non-negative skewness values.
For samples larger than 500, all observations remain in the fit and empirical
distribution function, while the n = 500 row is used for table lookup.
The KS comparison uses . For CvM, the stored n = 500
quantiles are divided by and compared with .
A list containing statistic, actual sample size n,
gamma1_hat, gamma1_used, and p.value.
Mateu-Figueras, G., Puig, P., and Pewsey, A. (2007). Goodness-of-fit tests for the skew-normal distribution when the parameters are estimated from the data. Communications in Statistics—Theory and Methods, 36(9), 1735–1755. doi:10.1080/03610920601126217
set.seed(123) x <- sn::rsn(50, xi = 0, omega = 1, alpha = 3) PBGoF_ks_test(x) PBGoF_cvm_test(x)set.seed(123) x <- sn::rsn(50, xi = 0, omega = 1, alpha = 3) PBGoF_ks_test(x) PBGoF_cvm_test(x)
Draws a QQ plot for a fitted skew-normal or skew-t distribution.
QQ.plot(data, model = "SN", main = NULL, ylab = "Observed quantiles", pch = 16, cex = 0.65, lwd = 2)QQ.plot(data, model = "SN", main = NULL, ylab = "Observed quantiles", pch = 16, cex = 0.65, lwd = 2)
data |
A numeric vector containing finite observations. |
model |
Either |
main |
Main plot title. The default is |
ylab |
Label for the vertical axis. |
pch |
Plotting character for the observed quantiles. |
cex |
Point size. |
lwd |
Line width of the reference line. |
This function is intended only for checking skew-normal and skew-t models. The reference line uses color "#D55E00". The horizontal-axis label is automatically set to Theoretical SN quantiles or Theoretical ST quantiles.
Invisibly returns a list containing the model, fitted parameters, theoretical quantiles, observed quantiles, and reference-line color.
set.seed(123) x <- sn::rsn(200, xi = 0, omega = 1, alpha = 5) QQ.plot(x, model = "SN")set.seed(123) x <- sn::rsn(200, xi = 0, omega = 1, alpha = 5) QQ.plot(x, model = "SN")
Tests skew-normal goodness of fit using a parametric bootstrap, re-estimating
the model in each bootstrap sample with sn.fit.robust().
sn.para.bootstrap.ks.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE) sn.para.bootstrap.cvm.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE)sn.para.bootstrap.ks.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE) sn.para.bootstrap.cvm.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE)
data |
A numeric vector containing at least 10 finite observations. |
B |
A positive integer giving the number of bootstrap samples. |
seed |
A single integer, or |
verbose |
Logical; whether to print a short summary. |
The KS function uses ; the CvM function uses the
Cramér–von Mises statistic. Failed fits are excluded and the p-value uses
the finite-simulation correction .
The names ending in .1 are compatibility aliases.
A single numeric bootstrap p-value with attributes statistic,
B, valid, and failed.
set.seed(123) x <- sn::rsn(50, xi = 0, omega = 1, alpha = 3) sn.para.bootstrap.ks.test(x, B = 99) sn.para.bootstrap.cvm.test(x, B = 99)set.seed(123) x <- sn::rsn(50, xi = 0, omega = 1, alpha = 3) sn.para.bootstrap.ks.test(x, B = 99) sn.para.bootstrap.cvm.test(x, B = 99)
Fits a skew-normal distribution by MLE, then falls back to default penalized MLE and matching-prior penalized MLE when necessary.
sn.fit.robust(data = NULL, para_form = c("DP", "CP"))sn.fit.robust(data = NULL, para_form = c("DP", "CP"))
data |
A numeric vector containing at least 10 finite observations. |
para_form |
Parameterization of the result: |
Robustness here concerns numerical fitting failures, not resistance to outliers or model contamination.
A named numeric vector containing parameter estimates and standard errors.
If all fitting procedures fail, all entries are NA.
set.seed(123) x <- sn::rsn(100, xi = 0, omega = 1, alpha = 5) sn.fit.robust(x, "DP") sn.fit.robust(x, "CP")set.seed(123) x <- sn::rsn(100, xi = 0, omega = 1, alpha = 5) sn.fit.robust(x, "DP") sn.fit.robust(x, "CP")
Draws a density-scale histogram of the observed data and overlays a
skew-normal density fitted by sn.fit.robust().
sn.plot.check( data, breaks = "FD", col = "grey83", border = "grey83", curve_col = "#6CC6C6", lwd = 2, main = NULL, xlab = "Values", add_rug = TRUE, ... )sn.plot.check( data, breaks = "FD", col = "grey83", border = "grey83", curve_col = "#6CC6C6", lwd = 2, main = NULL, xlab = "Values", add_rug = TRUE, ... )
data |
A numeric vector containing at least 10 finite observations. |
breaks |
Histogram breaks passed to |
col |
Fill color for the histogram. |
border |
Border color for histogram bars. |
curve_col |
Color of the fitted skew-normal density curve. |
lwd |
Line width of the fitted density curve. |
main |
Main plot title. |
xlab |
Label for the horizontal axis. |
add_rug |
Logical; whether to add observations as a rug plot. |
... |
Additional graphical arguments passed to |
This visual model check complements, but does not replace, the formal goodness-of-fit tests provided by PBGoF.
Invisibly returns a list containing the fitted DP parameters, histogram object, and coordinates of the fitted density curve.
set.seed(123) x <- sn::rsn(100, xi = 0, omega = 1, alpha = 4) sn.plot.check(x)set.seed(123) x <- sn::rsn(100, xi = 0, omega = 1, alpha = 4) sn.plot.check(x)
Tests a fitted univariate skew-t distribution using KS or Cramer–von Mises statistics. All four skew-t parameters are re-estimated in each bootstrap sample with st.fit.robust().
st.para.bootstrap.ks.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE) st.para.bootstrap.cvm.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE)st.para.bootstrap.ks.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE) st.para.bootstrap.cvm.test(data = NULL, B = 1000L, seed = 103L, verbose = FALSE)
data |
A numeric vector with at least 10 finite observations. |
B |
Positive integer number of bootstrap samples. |
seed |
Non-negative integer or |
verbose |
Logical; print a short summary. |
The KS statistic is sqrt(n) D. The CvM statistic is . Failed fits are excluded, and the finite-simulation correction is used.
A numeric bootstrap p-value with attributes statistic, B, valid, failed, and fit.
set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.para.bootstrap.ks.test(x, B=100) st.para.bootstrap.cvm.test(x, B=100)set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.para.bootstrap.ks.test(x, B=100) st.para.bootstrap.cvm.test(x, B=100)
Fits a univariate skew-t distribution using ordinary maximum likelihood, followed by Q-penalized maximum likelihood with alternative optimizers when needed.
st.fit.robust(data = NULL, para_form = c("DP", "CP"))st.fit.robust(data = NULL, para_form = c("DP", "CP"))
data |
A numeric vector with at least 10 finite observations. |
para_form |
Parameterization to return: |
DP contains xi, omega, alpha, and nu. CP contains the mean, standard deviation, skewness, and kurtosis when these moments exist. Robust refers to numerical fallback, not resistance to outliers.
A named numeric vector containing four estimates and their standard errors.
set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.fit.robust(x, "DP")set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.fit.robust(x, "DP")
Draws a density-scale histogram and overlays the skew-t density fitted by
st.fit.robust().
st.plot.check(data, breaks = "FD", col = "grey83", border = "grey83", curve_col = "#6CC6C6", lwd = 2, main = NULL, xlab = "Values", add_rug = TRUE, ...)st.plot.check(data, breaks = "FD", col = "grey83", border = "grey83", curve_col = "#6CC6C6", lwd = 2, main = NULL, xlab = "Values", add_rug = TRUE, ...)
data |
A numeric vector with at least 10 finite observations. |
breaks |
Histogram breaks passed to |
col |
Histogram fill color. |
border |
Histogram border color. |
curve_col |
Fitted density color. The default is |
lwd |
Fitted density line width. |
main |
Main title. |
xlab |
Horizontal-axis label. |
add_rug |
Logical; add observed values as a rug plot. |
... |
Additional graphical arguments passed to |
Invisibly returns fitted DP parameters, histogram information, and fitted curve coordinates.
set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.plot.check(x)set.seed(123) x <- sn::rst(100, alpha=3, nu=8) st.plot.check(x)