Learn R Programming

shotGroups (version 0.7.1)

groupShape: Shape analysis for a single group of bullet holes

Description

Assesses shape of a single group of bullet holes: Outlier analysis as well as numerical and graphical normality checks for a set of (x,y)-coordinates.

Usage

groupShape(xy, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget = 100, conversion = 'm2cm', ...)
"groupShape"(xy, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget = 100, conversion = 'm2cm', ...)
"groupShape"(xy, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget = 100, conversion = 'm2cm', ...)

Arguments

xy
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables X, Y or Point.X, Point.Y as well as Aim.X, Aim.Y giving the point of aim. If missing, point of aim is assumed to be in (0,0).
plots
logical: show diagrams?
bandW
for argument bandwith of smoothScatter.
outlier
method for outlier identification: mcd uses robust Mahalanobis distances (see aq.plot), pca uses robust principal components analysis (see pcout). Requires installing package mvoutlier.
dstTarget
a numerical value giving the distance to the target - used in MOA calculation. See getMOA.
conversion
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates - used in MOA calculation. See getMOA.
...
additional arguments passed to pcout with outlier='pca' - final sensitivity can be adjusted with option outbound, a sensible candidate value seems to be around 0.45.

Value

A list with the results from the numerical analyses and statistical tests.
corXY
correlation matrix of (x,y)-coordinates.
corXYrob
robust estimate of correlation matrix of (x,y)-coordinates.
Outliers
a vector of row indices for observations identified as outliers - only if package mvoutlier is installed.
ShapiroX
Shapiro-Wilk-Test result for normality of x-coordinates. Only for at most 5000 points. For more than 5000 points, replaced by Kolmogorov-Smirnov-Test in ksX.
ShapiroY
Shapiro-Wilk-Test result for normality of y-coordinates. Only for at most 5000 points. For more than 5000 points, replaced by Kolmogorov-Smirnov-Test in ksY.
multNorm
E-statistic-Test result for multivariate normality of (x,y)-coordinates - only available if package energy is installed.

Details

In addition to the numerical results listed below, this function produces the following diagrams:
  • a combined plot for multivariate outlier identification as produced by aq.plot - requires installing package mvoutlier
  • a chi-square Q-Q-plot for eyeballing multivariate normality as produced by chisq.plot, including a reference line with intercept 0 and slope 1
  • a heatmap of a non-parametric 2D-kernel density estimate for the (x,y)-coordinates as produced by smoothScatter together with group center and error ellipses (original and scaled by factor 2) based on a robust estimate for the covariance matrix (from covMcd using the MCD algorithm)
  • a Q-Q-plot of x-coordinates for eyeballing normality
  • a Q-Q-plot of y-coordinates for eyeballing normality
  • a histogram of x-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate
  • a histogram of y-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate

If package shiny is installed, an interactive web app for this functionality can be run with runGUI("analyze").

See Also

qqnorm, smoothScatter, hist, kernel, covMcd, shapiro.test, ks.test, mvnorm.etest, chisq.plot, aq.plot, pcout

Examples

Run this code
# coordinates given by a suitable data frame
res <- groupShape(DFsavage, bandW=4, outlier='mcd',
                  dstTarget=100, conversion='m2mm')
names(res)
res$corXY
res$Outliers
res$multNorm

# coordinates given by a matrix
## Not run: 
# xy <- matrix(round(rnorm(200, 0, 5), 2), ncol=2)
# groupShape(xy, bandW=1.6)
# ## End(Not run)

Run the code above in your browser using DataLab