Learn R Programming

mitml (version 0.3-1)

plot.mitml: Print diagnostic plots

Description

Generates diagnostic plots for assessing the convergence and autocorrelation behavior of pan's and jomo's MCMC algorithms.

Usage

## S3 method for class 'mitml':
plot(x, print=c("beta","psi","sigma"), group="all",
  trace=c("imputation","burnin","all"), smooth=3,
  export=c("none","png","pdf"), dev.args=list(), ...)

Arguments

x
An object of class mitml as produced by panImpute and jomoImpute.
print
A character vector containing one or several of "beta", "psi" or "sigma" denoting which parameters should be plotted. Default is to plot all parameters.
group
Either "all" or an integer denoting for which group plots should be generated. Used only when group has been specified in panImpute for group-wise imputation.
trace
One of "imputation", "burnin" or "all" denoting which part of the parameter chain should be used for the trace plot. Default plots only the iterations after burn-in.
smooth
A numeric value denoting the smoothing factor for the trend line in trace plots. Higher values correspond to less smoothing. Default is 3. If set to 0 or NULL, the trend line is suppressed.
export
(optional) A character string specifying if plots should be exported to file. If "png" or "pdf", then plots are printed into a folder named "mitmlPlots" in the current directory using either the png or pdf
dev.args
(optional) A named list containing additional arguments that are passed to the graphics device.
...
Parameters passed to the plotting functions.

Value

  • None (invisible NULL).

Details

The plot method generates a series of plots for the parameters of the imputation model which can be used for diagnostic purposes.

Setting print to "beta", "psi" and "sigma" will plot the fixed effects, the variances and covariances of random effects, and the variances and covariances of residuals, respectively. Each plotting window contains a trace plot (upper left), an autocorrelation plot (lower left), a kernel density approximation of the posterior distribution (upper right), and a posterior summary (lower right). The trace and smooth arguments can be used to influence how the trace plot is drawn, and what part of the chain should be used for it.

The plots are presented one at a time. To proceed with the next plot, the user may left-click in the plotting window or press "enter" while in the R console. No plots are displayed when exporting to file.

See Also

panImpute, jomoImpute

Examples

Run this code
data(studentratings)

# * Example 1: simple imputation

fml <- ReadDis + SES ~ ReadAchiev + (1|ID)
imp <- panImpute(studentratings, formula=fml, n.burn=1000, n.iter=100, m=5)

plot all parameters (default)
plot(imp)
plot(imp, print=c("beta","psi","sigma"))

plot fixed effects only
plot(imp, print="beta")

# export plots to file (using pdf device)
plot(imp, export="pdf", dev.args=list(width=9, height=4, pointsize=12))

# * Example 2: groupwise imputation

fml <- ReadDis + SES ~ ReadAchiev + (1|ID)
imp <- panImpute(studentratings, formula=fml, group=FedState, n.burn=1000,
       n.iter=100, m=5)

plot fixed effects for all groups (default for 'group')
plot(imp, print="beta", group="all")

plot fixed effects for first group only
plot(imp, print="beta", group=1)

Run the code above in your browser using DataLab