Univariate_Score_function {PlotNormTest}R Documentation

Graphical plots to assess the univarite noramality assumption of data.

Description

Score function of a univariate normal distribution is a straight line. A non-linear graph of score function estimator shows evidence of non-normality.

Outliers are detected using the 2-sigma bands method.

Usage

cox(x, P = NULL, lambda = 0.5, x.dist = NULL)

score_plot1D(x, P = NULL, lambda = 0.5, x.dist = NULL, ori.index = NULL)

Arguments

x

univariate data.

P

vector of weight.

lambda

smoothing parameter, default is 0.5.

x.dist

the minimum distance between two data points in vector x.

ori.index

original index of vector x, default is NULL when index is just the order.

Details

To avoid the singularity of coefficient matrices in spline method, points with distance less than x.dist are merged and weight of the representative points is updated by the summation of weight of discarded points.

Under null hypothesis, a unbiased estimator score function of a given data point x_k is

\hat{\psi}(x_k) = \dfrac{n - 4}{n - 2} \dfrac{x_k - \bar{X}_{-k}}{S_{-k}^2}

and if a_{k} is the estimate score from function cox at the point x_k, then

a_k\in \hat{\psi}(x_k) \pm 2 \sqrt{\hat{\text{Var}}(\hat{\psi}(x_k))}.

Hence points outside the 2-sigma bands are outliers.

Value

cox returns the estimate of score function.

score_plot1D returns score functions together with 2-sigma bands for outlier detection.

References

Ng PT (1994). “Smoothing Spline Score Estimation.” SIAM Journal on Scientific Computing, 15(5), 1003-1025. doi:10.1137/0915061, https://doi.org/10.1137/0915061.

Examples

set.seed(1)
x <- rnorm(100, 2, 4)
re <- cox(sort(x))
plot(re$x, re$a, xlab = "x", ylab = "Estimated Score",
 main = "Estimator of score function")
abline(0, 1)

set.seed(1)
x <- rnorm(100, 2, 4)
score_plot1D(sort(x))


[Package PlotNormTest version 1.0.1 Index]