MOVING STATISTIC PLOT
Name:
... MOVING STATISTIC PLOT
Type:
Purpose:
Plots the moving value of a statistic for a response variable.
Optionally, the moving statistic can be plotted against a groupid
variable.
Description:
It is sometimes useful to a compute a statistic over a "local"
region of a variable rather than the entire variable. The most
common example would be to compute a moving average for a variable.
Although this command is most commonly used for a location
statistic, it can in fact be used for any supported statistic (enter
HELP STATISTIC for a list of supported statistics).
The local area is defined by the FILTER WIDTH command. For example,
says that 5 points will be used to compute the specified statistic.
The command
SET MOVING DIRECTION <CENTER/LEFT/RIGHT>
defines the direction of the local region:
CENTER

=

the current row plus an equal number of rows
above and below the current row. For example,
if the FILTER WIDTH is set to 5, the local area
for row i will be rows i  2 to
i + 2.

LEFT

=

the current row plus the specified number of rows above the
current row. For example, if the FILTER WIDTH is set to 5,
the local area for row i will be rows i to
i + 4.

RIGHT

=

the current row minus the specified number of rows below the
current row. For example, if the FILTER WIDTH is set to 5,
the local area for row i will be rows i  4
to i.

The other issue is how the end points will be handled. This is
specified with the command
SET MOVING END POINT <SKIP/SYMMETRIC/PARTIAL>
where
SKIP

=

if the local region extends beyond the start or end point,
no output value will be generated for that row.

PARTIAL

=

if the local region extends beyond the start or end point,
the statistic will be computed for the subset of rows that
are within range.

SYMMETRIC

=

if the local region extends beyond the start or end point,
the statistic will be computed for the largest subset of
rows that maintains an equal number of rows above and below
the current row. This option is only supported if the
MOVING DIRECTION is CENTER.

The default is a FILTER WIDTH of 3, MOVING DIRECTION of CENTER, and
a MOVING END POINT of SKIP.
The <stat> STATISTIC PLOT can be used plot the value of a
statistic versus the index of a groupid variable. So if
you have 10 groups in your data, there will be 10 values of
the statistic computed.
The <stat> MOVING STATISTIC PLOT is a variant of the
STATISTIC PLOT.
There are two cases.
 If there is a single group in the data, then the
moving value of the statistic will be plotted
versus the sequence number. That is, plot
where
\( S_{Y_i} \) versus i = the value of the moving
statistic at point i.
A reference line will be drawn at the value of the statistic
for the full data set.
The appearance of these two traces is controlled by the first
two settings of the LINES, CHARACTERS, SPIKES, BARS, and
and associated attribute setting commands.
 If there are multiple groups in the data, then the process
above is repeated for each group. In this case, the
xcoordinates is the index of the full data set, not
just the current group. However, the moving statistic is
only computed for points in the current group. The group
sizes do not need to be equal.
The distinction between this command and the STATISTIC PLOT
is that the STATISTIC PLOT only plots the value of the
statistic for all points in the group while this command
plots the value of the moving statistic for all points
in the group. For example, if there are ten groups with
ten points each, the STATISTIC PLOT will plot ten points
while the MOVING STATISTIC PLOT will plot 100 points.
A reference line will be drawn for each group (the reference
value is the value of the statistic for all points in the
specific group).
The traces for the plot are defined in pairs. That is,
trace one is the moving statistics for group one, trace
two is the reference line for group one, trace three is
the moving statistics for group two, trace four is the
reference line for group two, and so on.
If you enter the command
SET MOVING STATISTIC PLOT GROUPS STACKED
then the x coordinate will start at one for each group.
In this case, no reference line is drawn.
To turn off the stacking option, enter
SET MOVING STATISTIC PLOT GROUPS DEFAULT
Syntax 1:
<stat> MOVING STATISTIC PLOT <y1> ... <yk>
<SUBSET/EXCEPT/FOR qualification>
where <stat> is one of Dataplot's supported statistics;
<y1> ... <yk> is a list of 1 to 3 response variables
(<stat> determines how many response variables);
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
For a list of supported statistics, enter
This syntax is for the case without groups in the data.
Syntax 2:
<stat> MOVING STATISTIC PLOT
<y1> ... <yk> <x>
<SUBSET/EXCEPT/FOR qualification>
where <stat> is one of Dataplot's supported statistics;
<y1> ... <yk> is a list of 1 to 3 response variables
(<stat> determines how many response variables);
<x> is a groupid variable;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
For a list of supported statistics, enter
This syntax is used for the case where there is a groupid
variable.
Examples:
MEAN MOVING STATISTIC PLOT Y
MEAN MOVING STATISTIC PLOT Y X
MEAN MOVING STATISTIC PLOT Y X SUBSET X > 2
SD MOVING STATISTIC PLOT Y
CORRELATION MOVING STATISTIC PLOT Y1 Y2
Note:
If the command
SET MOVING END POINT SKIP
is given, then some points at the beginning or end of the
data will not have the moving statistic computed. So if
i=3 is the first point at which the moving statistic is
computed, the xcoordinate will be set to 3, not 1.
Note:
The word STATISTIC is required in this command (i.e., MOVING PLOT
is not a synonym for MOVING STATISTIC PLOT). This is to avoid
conflicts with other commands.
Default:
Synonyms:
Related Commands:
Applications:
Exploratory Data Analysis
Implementation Date:
2015/5
The list of supported statistics is frequently updated. Enter
HELP STATISTICS
for a current list of supported statistics.
Program:
. Step 1: Read the data
.
dimension 40 columns
skip 25
read zarr13.dat y1
read berger1.dat y2 x2
read lew.dat y3
read gear.dat y4 x4
skip 0
.
. Step 2: Set some default plot control options
.
case asis
label case asis
tic mark label case asis
title case asis
title offset 2
y1label displacement 15
x1label displacement 12
multiplot scale factor 2
multiplot corner coordinates 5 5 95 95
.
. Step 3: Moving plots, no groups, single response variable
.
filter width 5
x1label Sequence
.
multiplot 2 2
.
title Mean Moving Statistic Plot
y1label Moving Mean
mean moving statistic plot y1
.
title Median Moving Statistic Plot
y1label Moving Median
median moving statistic plot y1
.
title SD Moving Statistic Plot
y1label Moving SD
standard deviation moving statistic plot y1
.
title Skewness Moving Statistic Plot
y1label Moving Skewness
skewness moving statistic plot y1
.
end of multiplot
.
just center
move 50 97
text Moving Statistic Plots for ZARR13.DAT (filter width 5)
.
y1label displacement
x1label displacement
.
. Step 4: Moving plots, no groups, two response variable
.
xlimits 0 120
.
title Correlation Moving Statistic Plot for BERGER1.DAT
y1label Moving Correlation
correlation moving statistic plot y2 x2
.
xlimits
.
. Step 5: Cumulative/moving plots, groups, one response variable
.
title Mean Moving Statistic Plot for GEAR.DAT
y1label Moving Mean
mean moving statistic plot y4 x4
