grouper {nnDiag} | R Documentation |
The purpose of this function is to produce an object that can be used in many of the diagnostic tools from this package. It orders the reference set elements with respect to predictions and breaks them into groups with an arbitrary number of elements. Also included in the output is the number of times each element was used as a neighbor in the kNN classification and the residuals.
grouper(reference.set, predicted.set, nnIndex, group.size = 25, best = TRUE)
reference.set |
vector of observed values |
predicted.set |
vector of predicted values |
nnIndex |
data.frame of nearest neighbors index |
group.size |
a single integer, number of elements to be in each group |
best |
logical indicating whether the function will use the exact
group.size input or if it will find the “best” size
nearest to the group.size input. |
The nnIndex
matrix will have a column for each corresponding k
used in the kNN classification. Each element in the matrix should be
in reference to the reference.set
vector position of the observed
value.
If the remainder number of data elements do not fill a
full group, the rest of that group will have NA
s as place
fillers. The best
argument is to reduce the number of
NA
s in the last group. When best
= TRUE
the function will find the “best” group size, which is near the
group.size
input, that best fits the number of elements in the
reference set. If best
is set to FALSE
it will use the
group.size
input exactly.
Returns an object of class
"nnDgrps"
,
which is a list containing the following components:
ordered.data |
data frame of the inputed data ordered by predictions |
reference.groups |
matrix of the groups of reference set elements where each column is a group. |
predicted.groups |
matrix of the groups of predicted set elements where each column is a group. |
residual.groups |
matrix of the groups of residuals where each column is a group. |
group.size |
the number of data elements in each group. |
Brian Walters walte137@msu.edu
McRoberts, R.E. (2009) Diagnostic tools for nearest neighbors techniques when used with satellite imagery, Remote Sensing of Environment. 113, 489–499.
Functions that use "nnDgrps"
objects: scedast
,
outInflu
, bias
data(LuceVolume) data(LuceVolume_indx) ##Using the defaults x <- grouper(LuceVolume$ref.volume, LuceVolume$pred.vol_k18, LuceVolume_indx) x ##Not using the defaults x <- grouper(LuceVolume$ref.volume, LuceVolume$pred.vol_k18, LuceVolume_indx, group.size = 37, best = FALSE) x