Learn R Programming

mi (version 0.10-2)

mi.scatterplot: Multiple Imputation Scatterplot

Description

A function for plotting observed and imputed values for a variable .

Usage

mi.scatterplot( Yobs, Yimp, X = NULL, xlab = NULL, ylab = NULL, 
                            main = "Imputed Variable Scatter Plot", 
                             display.zero = TRUE, gray.scale = FALSE, 
                              obs.col = rgb( 0, 0, 1 ), 
                              imp.col = rgb( 1, 0, 0 ), 
                              obs.pch = 20 , imp.pch = 20, 
                              obs.cex = 0.3, imp.cex = 0.3, 
                              obs.lty = 1  , imp.lty = 1, 
                              obs.lwd = 2.5, imp.lwd = 2.5, ... )
marginal.scatterplot ( data, object, use.imputed.X = FALSE, ...  )

Arguments

Yobs
observed values.
Yimp
imputed values.
X
variable to plot on the x axis.
xlab
label on the x axis.
ylab
label on the y axis.
display.zero
if set to FALSE zeros will not be displayed. Default is TRUE.
main
main title of the plot.
gray.scale
When set to TRUE, makes the plot into gray scale with predefined color and line type.
obs.col
color for the observed variable. Default is "blue".
imp.col
color for the imputed variable. Default is "red".
obs.pch
data symbol for observed variable. Default is 20.
imp.pch
data symbol for imputed variable. Default is 20.
obs.cex
text size for observed variable. Default is 0.3.
imp.cex
text size for imputed variable. Default is 0.3.
obs.lty
line type for observed variable. Default is 1.
imp.lty
line type for imputed variable. Default is 1.
obs.lwd
line width for observed variable. Default is 2.5.
imp.lwd
line width for imputed variable. Default is 2.5.
...
Other options for 'plot' function.
data
missing data.
object
mi object.
use.imputed.X
If you want to use the imputed X. Default is FALSE.

Value

  • A scatterplot with the observed and the imputed values plotted against a chosen variable.

Details

Since several data points can have the same data values, especially in discrete variables, small random number is added to each value so that points do not fall on top of each other. See help on jitter for more details. Lowess line is fitted to both imputed and observed data.

References

Yu-Sung Su, Andrew Gelman, Jennifer Hill, Masanao Yajima. (2011). Multiple Imputation with Diagnostics (mi) in R: Opening Windows into the Black Box. Journal of Statistical Software 45(2). Kobi Abayomi, Andrew Gelman and Marc Levy. (2008). Diagnostics for multivariate imputations. Applied Statistics 57, Part 3: 273--291. Andrew Gelman and Jennifer Hill. (2007). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.

See Also

mi, plot

Examples

Run this code
# true data
  x<-rnorm(100,0,1) # N(0,1)
  y<-rnorm(100,(1+2*x),1.2) # y ~ 1 + 2*x + N(0,1.2)
  # create artificial missingness on y
  y[seq(1,100,10)]<-NA
  dat.xy <- data.frame(x,y)
  # imputation
  imp.cont<-mi.continuous(y~x, data = dat.xy)
  mi.scatterplot(y,imputed(imp.cont,y))

Run the code above in your browser using DataLab