File: varDiff.Rd

package info (click to toggle)
r-cran-matrixstats 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,104 kB
  • sloc: ansic: 7,300; sh: 11; makefile: 2
file content (120 lines) | stat: -rw-r--r-- 4,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/varDiff.R
\name{varDiff}
\alias{varDiff}
\alias{sdDiff}
\alias{madDiff}
\alias{iqrDiff}
\alias{rowVarDiffs}
\alias{colVarDiffs}
\alias{rowSdDiffs}
\alias{colSdDiffs}
\alias{rowMadDiffs}
\alias{colMadDiffs}
\alias{rowIQRDiffs}
\alias{colIQRDiffs}
\title{Estimation of scale based on sequential-order differences}
\usage{
varDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

sdDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

madDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0,
  constant = 1.4826, ...)

iqrDiff(x, idxs = NULL, na.rm = FALSE, diff = 1L, trim = 0, ...)

rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)

colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L,
  trim = 0, ..., useNames = TRUE)
}
\arguments{
\item{x}{A \code{\link[base]{numeric}} \code{\link[base]{vector}} of length
N or a \code{\link[base]{numeric}} NxK \code{\link[base]{matrix}}.}

\item{idxs}{A \code{\link[base]{vector}} indicating subset of elements to
operate over. If \code{\link[base]{NULL}}, no subsetting is done.}

\item{na.rm}{If \code{\link[base:logical]{TRUE}}, missing values are
excluded.}

\item{diff}{The positional distance of elements for which the difference
should be calculated.}

\item{trim}{A \code{\link[base]{double}} in [0,1/2] specifying the fraction
of observations to be trimmed from each end of (sorted) \code{x} before
estimation.}

\item{...}{Not used.}

\item{constant}{A scale factor adjusting for asymptotically normal
consistency.}

\item{rows}{A \code{\link[base]{vector}} indicating subset of rows to
operate over. If \code{\link[base]{NULL}}, no subsetting is done.}

\item{cols}{A \code{\link[base]{vector}} indicating subset of columns to
operate over. If \code{\link[base]{NULL}}, no subsetting is done.}

\item{useNames}{If \code{\link[base:logical]{TRUE}} (default), names
attributes of the result are set, otherwise not.}
}
\value{
Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of
length 1, length N, or length K.
}
\description{
Estimation of scale based on sequential-order differences, corresponding to
the scale estimates provided by \code{\link[stats]{var}},
\code{\link[stats]{sd}}, \code{\link[stats]{mad}} and
\code{\link[stats]{IQR}}.
}
\details{
Note that n-order difference MAD estimates, just like the ordinary MAD
estimate by \code{\link[stats]{mad}}, apply a correction factor such that
the estimates are consistent with the standard deviation under Gaussian
distributions.

The interquartile range (IQR) estimates does \emph{not} apply such a
correction factor.  If asymptotically normal consistency is wanted, the
correction factor for IQR estimate is \code{1 / (2 * qnorm(3/4))}, which is
half of that used for MAD estimates, which is \code{1 / qnorm(3/4)}.  This
correction factor needs to be applied manually, i.e. there is no
\code{constant} argument for the IQR functions.
}
\references{
[1] J. von Neumann et al., \emph{The mean square successive
difference}.  Annals of Mathematical Statistics, 1941, 12, 153-162.\cr
}
\seealso{
For the corresponding non-differentiated estimates, see
\code{\link[stats]{var}}, \code{\link[stats]{sd}}, \code{\link[stats]{mad}}
and \code{\link[stats]{IQR}}.  Internally, \code{\link{diff2}}() is used
which is a faster version of \code{\link[base]{diff}}().
}
\author{
Henrik Bengtsson
}
\keyword{iteration}
\keyword{robust}
\keyword{univar}