This may be used to plot, or save plots of, samples in an object of
class pmc.ppc
. A variety of plots is provided.
# S3 method for pmc.ppc
plot(x, Style=NULL, Data=NULL, Rows=NULL,
PDF=FALSE, …)
This required argument is an object of class pmc.ppc
.
This optional argument specifies one of several styles of plots,
and defaults to NULL
(which is the same as
"Density"
). Styles of plots are indicated in quotes. Optional
styles include "Covariates"
, "Covariates, Categorical DV"
,
"Density"
, "DW"
, "DW, Multivariate, C"
,
"ECDF"
, "Fitted"
, "Fitted, Multivariate, C"
,
"Fitted, Multivariate, R"
, "Jarque-Bera"
,
"Jarque-Bera, Multivariate, C"
,
"Mardia"
, "Predictive Quantiles"
,
"Residual Density"
, "Residual Density, Multivariate, C"
,
"Residual Density, Multivariate, R"
,
"Residuals"
, "Residuals, Multivariate, C"
,
"Residuals, Multivariate, R"
, "Space-Time by Space"
,
"Space-Time by Time"
, "Spatial"
,
"Spatial Uncertainty"
, "Time-Series"
,
"Time-Series, Multivariate, C"
, and
"Time-Series, Multivariate, R"
. Details are given below.
This optional argument accepts the data set used when updating the
model. Data is required only with certain plot styles, including
"Covariates"
, "Covariates, Categorical DV"
,
"DW, Multivariate, C"
, "Fitted, Multivariate, C"
,
"Fitted, Multivariate, R"
,
"Jarque-Bera, Multivariate, C"
, "Mardia"
,
"Residual Density, Multivariate, C"
,
"Residual Density, Multivariate, R"
,
"Residuals, Multivariate, C"
,
"Residuals, Multivariate, R"
,
"Space-Time by Space"
, "Space-Time by Time"
,
"Spatial"
, "Spatial Uncertainty"
,
"Time-Series, Multivariate, C"
, and
"Time-Series, Multivariate, R"
.
This optional argument is for a vector of row numbers that
specify the records associated by row in the object of class
pmc.ppc
. Only these rows are plotted. The default is to
plot all rows. Some plots do not allow rows to be specified.
This logical argument indicates whether or not the user wants Laplace's Demon to save the plots as a .pdf file.
Additional arguments are unused.
This function can be used to produce a variety of posterior predictive
plots, and the style of plot is selected with the Style
argument. Below are some notes on the styles of plots.
Covariates
requires Data
to be specified, and also
requires that the covariates are named X
or x
. A plot
is produced for each covariate column vector against yhat, and is
appropriate when y is not categorical.
Covariates, Categorical DV
requires Data
to be
specified, and also requires that the covariates are named X
or
x
. A plot is produced for each covariate column vector against
yhat, and is appropriate when y is categorical.
Density
plots show the kernel density of the posterior
predictive distribution for each selected row of y (all are selected
by default). A vertical red line indicates the position of the
observed y along the x-axis. When the vertical red line is close to
the middle of a normal posterior predictive distribution, then there
is little discrepancy between y and the posterior predictive
distribution. When the vertical red line is in the tail of the
distribution, or outside of the kernel density altogether, then
there is a large discrepancy between y and the posterior predictive
distribution. Large discrepancies may be considered outliers, and
moreover suggest that an improvement in model fit should be
considered.
DW
plots the distributions of the Durbin-Watson (DW) test
statistics (Durbin and Watson, 1950), both observed
(
DW, Multivariate, C
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These plots compare each column-wise
vector of residuals with a univariate Durbin-Watson test, as in
DW
above. This plot is appropriate when Y is multivariate, not
categorical, and residuals are desired to be tested column-wise for
first-order autocorrelation.
ECDF
(Empirical Cumulative Distribution Function) plots compare
the ECDF of y with three ECDFs of yhat based on the 2.5%, 50%
(median), and 97.5% of its distribution. The ECDF(y) is defined as
the proportion of values less than or equal to y. This plot is
appropriate when y is univariate and at least ordinal.
Fitted
plots compare y with the probability interval of its
replicate, and provide loess smoothing. This plot is appropriate when
y is univariate and not categorical.
Fitted, Multivariate, C
requires Data
to be
specified, and also requires that variable Y
exists in the data
set with exactly that name. These plots compare each column-wise
vector of y in Y with its replicates and provide loess smoothing.
This plot is appropriate when Y is multivariate, not categorical, and
desired to be seen column-wise.
Fitted, Multivariate, R
requires Data
to be
specified, and also requires that variable Y
exists in the data
set with exactly that name. These plots compare each row-wise
vector of y in Y with its replicates and provide loess smoothing.
This plot is appropriate when Y is multivariate, not categorical, and
desired to be seen row-wise.
Jarque-Bera
plots the distributions of the Jarque-Bera (JB)
test statistics (Jarque and Bera, 1980), both observed
(
Jarque-Bera, Multivariate, C
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These plots compare each column-wise
vector of residuals with a univariate Jarque-Bera test, as in
Jarque-Bera
above. This plot is appropriate when Y is
multivariate, not categorical, and residuals are desired to be
tested column-wise for normality.
Mardia
plots the distributions of the skewness (K3) and
kurtosis (K4) test statistics (Mardia, 1970), both observed
(Mardia
requires Data
to
be specified, and also requires that variable Y
exist in the
data set with exactly that name. Y
must be a
Predictive Quantiles
plots compare y with the predictive
quantile (PQ) of its replicate. This may be useful in looking for
patterns with outliers. Instances outside of the gray lines are
considered outliers.
Residual Density
plots the residual density of the median of
the samples. A vertical red line occurs at zero. This plot may be
useful for inspecting a distributional assumption of residual
variance. This plot is appropriate when y is univariate and
continuous.
Residual Density, Multivariate C
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These are column-wise plots of residual
density, given the median of the samples. These plots may be useful
for inspecting a distributional assumption of residual variance.
This plot is appropriate when Y is multivariate, continuous, and
densities are desired to be seen column-wise.
Residual Density, Multivariate R
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These are row-wise plots of residual
density, given the median of the samples. These plots may be useful
for inspecting a distributional assumption of residual variance.
This plot is appropriate when Y is multivariate, continuous, and
densities are desired to be seen row-wise.
Residuals
plots compare y with its residuals. The probability
interval is plotted as a line. This plot is appropriate when y
is univariate.
Residuals, Multivariate, C
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These are plots of each column-wise
vector of residuals. The probability interval is plotted as a
line. This plot is appropriate when Y is multivariate, not
categorical, and the residuals are desired to be seen column-wise.
Residuals, Multivariate, R
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These are plots of each row-wise
vector of residuals. The probability interval is plotted as a
line. This plot is appropriate when Y is multivariate, not
categorical, and the residuals are desired to be seen row-wise.
Space-Time by Space
requires Data
to be specified, and
also requires that the following variables exist in the data set with
exactly these names: latitude
, longitude
, S
, and
T
. These space-time plots compare the S x T matrix Y with the S
x T matrix Yrep, producing one time-series plot per point s in space,
for a total of S plots. Therefore, these are time-series plots for
each point s in space across T time-periods. See Time-Series
plots below.
Space-Time by Time
requires Data
to be specified, and
also requires that the following variables exist in the data set with
exactly these names: latitude
, longitude
, S
, and
T
. These space-time plots compare the S x T matrix Y with the S
x T matrix Yrep, producing one spatial plot per time-period, and T
plots will be produced. See Spatial
plots below.
Spatial
requires Data
to be specified, and also requires
that the following variables exist in the data set with exactly these
names: latitude
and longitude
. This spatial plot shows
yrep plotted according to its coordinates, and is color-coded so that
higher values of yrep become more red, and lower values become more
yellow.
Spatial Uncertainty
requires Data
to be specified, and
also requires that the following variables exist in the data set with
exactly these names: latitude
and longitude
. This
spatial plot shows the probability interval of yrep plotted according
to its coordinates, and is color-coded so that wider probability
intervals become more red, and lower values become more yellow.
Time-Series
plots compare y with its replicate, including the
median and probability interval quantiles. This plot is appropriate
when y is univariate and ordered by time.
Time-Series, Multivariate, C
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These plots compare each column-wise
time-series in Y with its replicate, including the median and
probability interval quantiles. This plot is appropriate when y is
multivariate and each time-series is indexed by column in Y.
Time-Series, Multivariate, R
requires Data
to be
specified, and also requires that variable Y
exist in the data
set with exactly that name. These plots compare each row-wise
time-series in Y with its replicate, including the median and
probability interval quantiles. This plot is appropriate when y is
multivariate and each time-series is indexed by row in Y, such as is
typically true in panel models.
Durbin, J., and Watson, G.S. (1950). "Testing for Serial Correlation in Least Squares Regression, I." Biometrika, 37, p. 409--428.
Jarque, C.M. and Bera, A.K. (1980). "Efficient Tests for Normality, Homoscedasticity and Serial Independence of Regression Residuals". Economics Letters, 6(3), p. 255--259.
Mardia, K.V. (1970). "Measures of Multivariate Skewness and Kurtosis with Applications". Biometrika, 57(3), p. 519--530.
PMC
and
predict.pmc
.
# NOT RUN {
### See the PMC function for an example.
# }
Run the code above in your browser using DataLab