| 42333 |
ripley |
1 |
% File src/library/stats/man/monthplot.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2007 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27497 |
ripley |
6 |
\name{monthplot}
|
| 56186 |
murdoch |
7 |
\alias{monthplot}
|
| 27497 |
ripley |
8 |
\alias{monthplot.default}
|
|
|
9 |
\alias{monthplot.ts}
|
|
|
10 |
\alias{monthplot.stl}
|
|
|
11 |
\alias{monthplot.StructTS}
|
|
|
12 |
|
|
|
13 |
\title{
|
| 35072 |
ripley |
14 |
Plot a Seasonal or other Subseries from a Time Series
|
| 27497 |
ripley |
15 |
}
|
|
|
16 |
\description{
|
|
|
17 |
These functions plot seasonal (or other) subseries of a time series.
|
|
|
18 |
For each season (or other category), a time series is plotted.
|
|
|
19 |
}
|
| 35072 |
ripley |
20 |
\usage{
|
| 27497 |
ripley |
21 |
monthplot(x, \dots)
|
| 35072 |
ripley |
22 |
|
| 44243 |
ripley |
23 |
\method{monthplot}{stl}(x, labels = NULL, ylab = choice, choice = "seasonal",
|
|
|
24 |
\dots)
|
| 35072 |
ripley |
25 |
|
|
|
26 |
\method{monthplot}{StructTS}(x, labels = NULL, ylab = choice, choice = "sea", \dots)
|
|
|
27 |
|
|
|
28 |
\method{monthplot}{ts}(x, labels = NULL, times = time(x), phase = cycle(x),
|
| 27497 |
ripley |
29 |
ylab = deparse(substitute(x)), \dots)
|
| 35072 |
ripley |
30 |
|
| 49086 |
ripley |
31 |
\method{monthplot}{default}(x, labels = 1L:12L,
|
| 35072 |
ripley |
32 |
ylab = deparse(substitute(x)),
|
| 49086 |
ripley |
33 |
times = seq_along(x),
|
|
|
34 |
phase = (times - 1L)\%\%length(labels) + 1L, base = mean,
|
| 36816 |
ripley |
35 |
axes = TRUE, type = c("l", "h"), box = TRUE,
|
| 61433 |
ripley |
36 |
add = FALSE,
|
|
|
37 |
col = par("col"), lty = par("lty"), lwd = par("lwd"),
|
| 60727 |
murdoch |
38 |
col.base = col, lty.base = lty, lwd.base = lwd, ...)
|
| 27497 |
ripley |
39 |
}
|
|
|
40 |
\arguments{
|
|
|
41 |
\item{x}{Time series or related object.}
|
| 42961 |
ripley |
42 |
\item{labels}{Labels to use for each \sQuote{season}.}
|
| 35072 |
ripley |
43 |
\item{ylab}{y label.}
|
| 27497 |
ripley |
44 |
\item{times}{Time of each observation.}
|
| 42961 |
ripley |
45 |
\item{phase}{Indicator for each \sQuote{season}.}
|
| 27497 |
ripley |
46 |
\item{base}{Function to use for reference line for subseries.}
|
|
|
47 |
\item{choice}{Which series of an \code{stl} or \code{StructTS} object?}
|
| 35072 |
ripley |
48 |
\item{\dots}{Arguments to be passed to the default method or
|
|
|
49 |
graphical parameters.}
|
| 61160 |
ripley |
50 |
\item{axes}{Should axes be drawn (ignored if \code{add = TRUE})?}
|
| 35072 |
ripley |
51 |
\item{type}{Type of plot. The default is to join the points with
|
|
|
52 |
lines, and \code{"h"} is for histogram-like vertical lines.}
|
| 74363 |
maechler |
53 |
\item{box}{Should a box be drawn (ignored if \code{add = TRUE})?}
|
| 35072 |
ripley |
54 |
\item{add}{Should thus just add on an existing plot.}
|
| 60727 |
murdoch |
55 |
\item{col, lty, lwd}{Graphics parameters for the series.}
|
|
|
56 |
\item{col.base, lty.base, lwd.base}{Graphics parameters for the
|
|
|
57 |
segments used for the reference lines.}
|
| 27497 |
ripley |
58 |
}
|
|
|
59 |
\details{
|
|
|
60 |
These functions extract subseries from a time series and plot them
|
|
|
61 |
all in one frame. The \code{\link{ts}}, \code{\link{stl}}, and
|
|
|
62 |
\code{\link{StructTS}} methods use the internally recorded frequency and
|
|
|
63 |
start and finish times to set the scale and the seasons. The default
|
|
|
64 |
method assumes observations come in groups of 12 (though this can be
|
|
|
65 |
changed).
|
|
|
66 |
|
|
|
67 |
If the \code{labels} are not given but the \code{phase} is given, then
|
|
|
68 |
the \code{labels} default to the unique values of the \code{phase}. If
|
|
|
69 |
both are given, then the \code{phase} values are assumed to be indices
|
|
|
70 |
into the \code{labels} array, i.e., they should be in the range
|
|
|
71 |
from 1 to \code{length(labels)}.
|
|
|
72 |
}
|
|
|
73 |
\value{
|
|
|
74 |
These functions are executed for their side effect of
|
|
|
75 |
drawing a seasonal subseries plot on the current graphical
|
|
|
76 |
window.
|
|
|
77 |
}
|
|
|
78 |
\author{Duncan Murdoch}
|
|
|
79 |
\references{
|
|
|
80 |
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
|
|
|
81 |
\emph{The New S Language}.
|
| 47262 |
ripley |
82 |
Wadsworth & Brooks/Cole.
|
| 27497 |
ripley |
83 |
}
|
|
|
84 |
\seealso{
|
|
|
85 |
\code{\link{ts}}, \code{\link{stl}}, \code{\link{StructTS}}
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
\examples{
|
| 41508 |
ripley |
89 |
require(graphics)
|
|
|
90 |
|
| 27497 |
ripley |
91 |
## The CO2 data
|
|
|
92 |
fit <- stl(log(co2), s.window = 20, t.window = 20)
|
|
|
93 |
plot(fit)
|
|
|
94 |
op <- par(mfrow = c(2,2))
|
|
|
95 |
monthplot(co2, ylab = "data", cex.axis = 0.8)
|
|
|
96 |
monthplot(fit, choice = "seasonal", cex.axis = 0.8)
|
|
|
97 |
monthplot(fit, choice = "trend", cex.axis = 0.8)
|
|
|
98 |
monthplot(fit, choice = "remainder", type = "h", cex.axis = 0.8)
|
|
|
99 |
par(op)
|
|
|
100 |
|
|
|
101 |
## The CO2 data, grouped quarterly
|
|
|
102 |
quarter <- (cycle(co2) - 1) \%/\% 3
|
|
|
103 |
monthplot(co2, phase = quarter)
|
|
|
104 |
|
|
|
105 |
## see also JohnsonJohnson
|
|
|
106 |
}
|
|
|
107 |
\keyword{ hplot }
|
|
|
108 |
\keyword{ ts }
|