Univariate_Score_function | R Documentation |
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.
cox(x, P = NULL, lambda = 0.5, x.dist = NULL)
score_plot1D(x, P = NULL, lambda = 0.5, x.dist = NULL, ori.index = NULL)
x |
univariate data. |
P |
vector of weight. |
lambda |
smoothing parameter, default is |
x.dist |
the minimum distance between two data points in vector x. |
ori.index |
original index of vector x, default is |
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.
cox
returns the estimate of score function.
x
: The updated univariate data if merging happens.
a
: Score value estimated at x
.
P
: Updated weight (if merging happens).
slt
: Index of merged data point
(is NULL
if x.dist = NULL
).
score_plot1D
returns score functions together with
2-sigma bands for outlier detection.
plot
: plot of estimate score function and its band.
outlier
: index of outliers.
ref:sp_estimatePlotNormTest
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.