Learn R Programming

tsforecast (version 1.3.0)

tslineplot: Time Series Line Plots

Description

Produce line plot of a given univariate time series.

Usage

tslineplot(
  x,
  t = NULL,
  pred = NULL,
  pred.t = NULL,
  cil = NULL,
  ciu = NULL,
  ci.t = NULL,
  trend = c("none", "linear", "smooth"),
  title = NULL,
  x.name = NULL,
  pred.name = "Predicted",
  x.lwidth = 0.7,
  pred.lwidth = 0.7,
  x.col = "darkgrey",
  pred.col = "steelblue4",
  ci.col = "royalblue",
  t.name = "Date/Time",
  t.text.angle = 90,
  t.numbreak = 10,
  ylim = NULL
)

Value

A line plot of x will be displayed with no further values or objects returned.

Arguments

x

a univariate time series object or a numeric vector or matrix.

t

a vector or list of time periods in which the series values were observed. The length of t must be identical to the length of x.

pred

a vector of predicted or forecasted values of a univariate time series. This parameter can be omitted. Default is NULL.

pred.t

a vector of time periods in which the predicted or forecasted values of a univariate time series are estimated. This parameter can be omitted. Default is NULL.

cil

a vector of the prediction intervals' lower limits. Only necessary if pred and pred.t are provided. This parameter can be omitted. Default is NULL.

ciu

a vector of the prediction intervals' upper limits. Only necessary if pred and pred.t are provided. This parameter can be omitted. Default is NULL.

ci.t

a vector of the time periods in which the prediction intervals are estimated.This parameter can be omitted. Default is NULL.

trend

indicate whether a trend line should be included in the time series plot. Available options are `none`, `linear`, and `smooth`. If `linear`, a straight trend line estimated by linear regression model will be included. If `smooth`, the trend line will be estimated by LOESS regression model. Default is NULL, indicating that no trend line should be displayed.

title

title of the time series line plot.

x.name

name of the series. If omitted here, the series name found by tsname() will be taken over here. If tsname() is NULL, the variable name will be used instead. Default is NULL.

pred.name

name of the series' predicted/forecasted values. Only necessary if pred and pred.t are provided. Default is `Predicted`.

x.lwidth

line width of the series line plot. Default is 0.7.

pred.lwidth

line width of the line plot for the predicted/forecasted values. Default is 0.7.

x.col

line colour of the time series line plot. Default is `darkgrey`.

pred.col

line colour of the line plot for the predicted/forecasted values. Default is `steelblue4`.

ci.col

area colour of the prediction intervals. Default is `royalblue`.

t.name

name of the x-axis (time axis). Default is `Date/Time`.

t.text.angle

angle of the tick labels on the x-axis (time axis). Default is 90 (vertical).

t.numbreak

number of tick labels on the x-axis (time axis). Default is 10.

ylim

value limit of the y-axis. The values should be specified in c(lower_limit, upper_limit), where lower_limit and upper_limit are the values of the smallest and largest number of the y-axis, respectively. Default is NULL.

Author

Ka Yui Karl Wu

Details

If x is a ts object, parameter t can be omitted. You can convert a vector, a matrix or data frame column using tsconvert to a ts object.

Examples

Run this code
tslineplot(airport$Travellers, trend = "linear")

Run the code above in your browser using DataLab