Learn R Programming

mpt (version 0.3-0)

plot.mpt: Diagnostic Plot for MPT Models

Description

Plots MPT residuals against fitted values.

Usage

## S3 method for class 'mpt':
plot(x, showID = TRUE,
  xlab = "Predicted response probabilities", ylab = "Deviance residuals",
  \dots)

Arguments

x
an object of class mpt, typically the result of a call to mpt.
showID
logical. Should the treeid's be plotted? Defaults to TRUE.
xlab, ylab, ...
graphical parameters passed to plot.

Details

The deviance residuals are plotted against the predicted response probabilities. If showID is true, plotting symbols are the treeid's used when the model was fit.

See Also

mpt, residuals.mpt.

Examples

Run this code
## Compare two constrained MPT models

data(proact)

mpt1 <- mpt(freq ~ list(
  p1*q1*r1,
  p1*q1*(1 - r1),
  p1*(1 - q1)*r1,
  (1 - p1) + p1*(1 - q1)*(1 - r1),

  p2*q2*r2,
  p2*q2*(1 - r2),
  p2*(1 - q2)*r2,
  (1 - p2) + p2*(1 - q2)*(1 - r2),

  p3*q3*r3,
  p3*q3*(1 - r3),
  p3*(1 - q3)*r3,
  (1 - p3) + p3*(1 - q3)*(1 - r3)
), proact[proact$test == 1,], constr = list(p=c("p1", "p2", "p3")))

mpt2 <- mpt(mpt1$formula, proact[proact$test == 1,],
  constr = list(q=c("q1", "q2", "q3")))

par(mfrow = c(1,2))                   # residuals versus fitted values
plot(mpt1, main = "p constrained", ylim = c(-3, 3.5))  # good fit
plot(mpt2, main = "q constrained", ylim = c(-3, 3.5))  # bad fit

Run the code above in your browser using DataLab