Learn R Programming

imputeTS (version 1.5)

plotNA.imputations: Visualize Imputed Values

Description

Visualize the imputed values in a time series.

Usage

plotNA.imputations(x.withNA, x.withImputations, x.withTruth = NULL,
  legend = T, main = "Visualization Imputed Values", xlab = "Time",
  ylab = "Value", colWithTruth = "green3", colLines = "black",
  colWithImputations = "indianred2", colWithNA = "steelblue2",
  ylim = c(min(c(x.withImputations, x.withTruth), na.rm = T),
  max(c(x.withImputations, x.withTruth), na.rm = T)), pch = 20, cex = 0.8,
  ...)

Arguments

x.withNA
Numeric Vector or Time Series (ts) object with NAs before imputation
x.withImputations
Numeric Vector or Time Series (ts) object with NAs replaced by imputed values
x.withTruth
Numeric Vector or Time Series (ts) object with the real values. (can be set to NULL if not known)
legend
If TRUE a legend is shown at the bottom of the plot. A custom legend can be obtained by setting this parameter to FALSE and using legend function
main
Main title for the plot
xlab
Label for x axis of the plot
ylab
Label for y axis of plot
colWithTruth
Defines the color of the real values (truth) for the NA values.
colLines
Defines the color of the lines connecting non-NA observations.
colWithImputations
Defines the color for the imputed values.
colWithNA
Defines the color of the non-NA observations.
ylim
the y limits of the plot
pch
Either an integer specifying a symbol or a single character to be used as the default in plotting points.
cex
A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default.
...
Additional graphical parameters that can be passed through to plot

Details

This plot can be used, to visualize the imputed values for a time series. Therefore the imputed values (filled NA gaps) are shown in a different color than the other values. If the real values (truth) behind the NA gaps are known these are also added in a different color.

See Also

plotNA.distribution,plotNA.distributionBar, plotNA.gapsize

Examples

Run this code
#Prerequisite: Load a time series with missing values and perform an imputation
x <- tsAirgap

#Perform imputation for x using na.mean
x.imp <- na.mean(x)


#Example 1: Visualize the imputed values in the time series
plotNA.imputations(x, x.imp)


#Example 2: Visualize the imputed values and the true values in the time series
plotNA.imputations(x, x.imp, tsAirgapComplete)

Run the code above in your browser using DataLab