Learn R Programming

imputeTestbench (version 3.0.3)

plot_impute: Plot imputations

Description

Plot imputations for data from multiple methods

Usage

plot_impute(dataIn, smps = "mcar", methods = c("na.approx",
  "na.interp", "na_interpolation", "na.locf", "na_mean"),
  methodPath = NULL, blck = 50, blckper = TRUE, missPercent = 50,
  showmiss = FALSE, addl_arg = NULL)

Arguments

dataIn

input ts for testing

smps

chr string indicating sampling type for generating missing data, see details

methods

chr string of imputation methods to use, one to many. A user-supplied function can be included if MethodPath is used.

methodPath

chr string of location of script containing one or more functions for the proposed imputation method(s)

blck

numeric indicating block sizes as a percentage of the sample size for the missing data, applies only if smps = 'mar'

blckper

logical indicating if the value passed to blck is a percentage of the sample size for missing data, otherwise blck indicates number of observations

missPercent

numeric for percent of missing values to be considered

showmiss

logical if removed values missing from the complete dataset are plotted

addl_arg

arguments passed to other imputation methods as a list of lists, see details.

Value

A ggplot object showing the imputed data for each method. Red points are labelled as 'imputed' and blue points are labelled as 'retained' from the original data set. Missing data that were removed can be added to the plot as open circles if showmiss = TRUE. See the examples for modifying the plot.

Details

See the documentation for impute_errors for an explanation of the arguments.

Examples

Run this code
# NOT RUN {
# default
plot_impute(dataIn = nottem)

# change missing percent total
plot_impute(dataIn = nottem, missPercent = 10)

# show missing values
plot_impute(dataIn = nottem, showmiss = TRUE)

# use mar sampling
plot_impute(dataIn = nottem, smps = 'mar')

# change the plot aesthetics
# }
# NOT RUN {
library(ggplot2)
p <- plot_impute(dataIn = nottem, smps = 'mar')
p + scale_colour_manual(values = c('black', 'grey'))
p + theme_minimal()
p + ggtitle('Imputation examples with different methods')
p + scale_y_continuous('Temp at Nottingham Castle (F)')
# }

Run the code above in your browser using DataLab