| wp.twin {AGD} | R Documentation |
Superposes two worm plots from GAMLSS fitted objects. This is a diagnostic tool for comparing two solutions.
wp.twin(obj1, obj2 = NULL, xvar = NULL, xvar.column = 2, n.inter = 16, show.given = FALSE, ylim.worm = 0.5, line = FALSE, cex = 1, col1 = "black", col2 = "orange", warnings = FALSE, ...)
obj1 |
a GAMLSS fitted object |
obj2 |
an optional second GAMLSS fitted object |
xvar |
the explanatory variable against which the worm plots will be plotted |
xvar.column |
the number referring to the column of |
n.inter |
the number of intervals in which the explanatory variable |
show.given |
whether to show the x-variable intervals in the top of the graph, default is |
ylim.worm |
for multiple plots, this values is the y-variable limit, default value is |
line |
whether to plot the polynomial line in the worm plot, default value is |
cex |
the cex plotting parameter with default |
col1 |
the color for the points of |
col2 |
the color for the points of |
warnings |
a logical indicating whether warnings should be produced. The default |
... |
for extra arguments, |
This function is a customized version of the wp() function found in the gamlss package. Function
wp.twin() allows overplotting of two worm plots, each in its own color.
The points of obj1 are plotted first, the points of obj2 are superposed.
This twin worm plot provide a visual assessment of the differences between the solutions.
Extra arguments can be specified (e.g. xvar) that are passed down to the wp() function of gamlss
if specified.
The worm plot is a detrended normal QQ-plot that highlight departures from normality.
Argument xvar takes priority over xvar.column. The xvar variable is cut into n.iter
intervals with an equal number observations and detrended normal QQ (i.e. worm) plots for each interval are plotted.
This is a way of highlighting failures of the model within different ranges of the
explanatory variable.
If line=TRUE and n.inter>1, the fitted coefficients from fitting cubic polynomials to the residuals (within each x-variable interval) can be obtain by e.g.
coeffs<-wp.twin(model1,xvar=x,n.iner=9). van Buuren et al. (2001) used these residuals to identify regions (intervals) of the
explanatory variable within which the model does not fit adequately the data (called "model violation")
For multiple plots the xvar intervals and the coefficients of the fitted cubic
polynomials to the residuals (within each xvar interval) are returned.
Stef van Buuren, using R code of Mikis Stasinopoulos and Bob Rigby
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.
van Buuren and Fredriks M. (2001) Worm plot: simple diagnostic device for modelling growth reference curves. Statistics in Medicine, 20, 1259–1277. http://www.stefvanbuuren.nl/publications/Worm plot - Stat Med 2001.pdf
van Buuren and Fredriks M. (2007) Worm plot to diagnose fit in quantile regression. Statistical Modelling, 7, 4, 363–376. http://www.stefvanbuuren.nl/publications/WP quantile regression - Stat Mod 2007.pdf
data(abdom) a <- gamlss(y~cs(x,df=1),sigma.fo=~cs(x,0),family=LO,data=abdom) b <- gamlss(y~cs(x,df=3),sigma.fo=~cs(x,1),family=LO,data=abdom) coeff1 <- wp.twin(a,b,line=TRUE) coeff1 rm(a,b,coeff1)