Plot method for segmented mixed objects
plot.segmented.lme.RdTakes a fitted segmented.lme object returned by segmented.lme() and plots (or adds)
the fitted broken-line relationship for the segmented term.
Usage
# S3 method for class 'segmented.lme'
plot(x, level=1, id = NULL, res = TRUE, pop = FALSE, offs=0, yscale = 1, xscale = 1,
n.plot, pos.leg = "topright", vline = FALSE, lines = TRUE,
by=NULL, add=FALSE, conf.level=0, withI=TRUE, vcov.=NULL, shade=FALSE,
drop.var=NULL, text.leg=NULL, id.name=TRUE, ci.psi.pop=-1, ...)Arguments
- x
Object of class
"segmented.lme"- level
An integer giving the level of grouping to be used when computing the segmented relationship(s).
level=0means depending on fixed effects estimates only (such estimates are also said, to some extend, 'population' or 'marginal' estimates), otherewise the segmented lines will also depend on the random effects predictions.- id
A scalar or vector meaning which subjects profiles have to be drawn. If
NULL(default) all profiles are drawn. Ignored iflevel=0.- res
If
TRUE, the data points are also drawn. Ignored iflevel=0.- pop
if
TRUE, the fitted segmented relationships based on fixed-effects only is also portrayed. Ignored iflevel=0.- offs
Values (scalar or 100-length) to be added to the fitted values before plotting. Only if
level=0.- yscale
If
>= 0, the same and common y-scale is used for all 'subjects' (panels); otherwise the y-scale will depend on the actual (observed and fitted) values for each 'subject'.- xscale
If
>= 0, the same and common x-scale is used for all 'subjects' (panels); otherwise the x-scale will depend on the actual observed values of the segmented covariate for each 'subject'.- n.plot
a vector to be passed to
par(mfrow=c(..))for plotting multiple panels (should be coherent withlength(id)). If missing, it is computed automatically depending onlength(id). Typen.plot=1to draw all the segmented profiles on the same panel.- pos.leg
a character ('topright', 'topleft',...) meaning the location of the legend. Set
NULLfor no legend.- vline
logical, if
TRUEa vertical dashed segment is added to emphasize the breakpoint location.- lines
logical, if
FALSEpoints, rather than lines, are used to portray the segmented relationships.- by
A named list indicating covariate names and corresponding values affecting the fitted segmented relationship. For instance:
by=list(sex="male",z=.2), provided that the variablessexandzaffect the segmented relationship. Effective only iflevel=0.- add
If
TRUEthe (fixed-effect) fitted segmented relationship is added to the current plot. Effective only iflevel=0.- conf.level
The confidence level for pointwise confidence intervals. Effective only if
level=0.- withI
If
TRUE, the level 0 segmented relationship is computed with the model intercept. Effective only iflevel=0.- vcov.
The fixed effects covariance matrix. If
NULL, it is computed byvcov.segmented.lme(). Effective only iflevel=0.- shade
If
TRUE(andconf.level>0) the area within the pointiwise CIs is shaded. Effective only iflevel=0.- drop.var
Possible coefficient names to be removed before computing the segmented relationship (E.g. the group-specific intercept.).
- text.leg
If specified (and
pos.leghas been also specified), it is the legend text. Effective only iflevel=0.- id.name
If
pos.legis different fromNULL,id.name=TRUEwill portray the cluster variable name along the value. Namelyid.name=TRUEleads to 'country = italy' on each panel, whileid.name=FALSEto 'italy'.- ci.psi.pop
Should the point estimate and CI for the population breakpoint be added? If
ci.psi.pop>0both the point estimate and CI (at levelci.psi.pop) are added; ifci.psi.pop=0only the point estimate.- ...
additional arguments, such as
ylab,xlab,ylimandxlim;l.col,l.lwd,l.lty(for the fitted individual lines - can be vectors and will be recycled);p.col, p.lwd, p.ltyfor the population line (ifpop=TRUE);col, cex, pchfor the data points (ifres=TRUE);t.colfor the legend color, ifpos.legis notNULL. Iflevel=0andconf.level>0,ltyandlwdcan be vectors.
Details
The function plots the 'subject'-specific segmented profiles for the 'subjects' specificed in id or, if level=0, the fitted segmented relationship based on fixed effects only. The number of panels to drawn is actually the minimum between length(id) and prod(n.plot), but if n.plot=c(1,1) (or also simply n.plot=1), the `individual' profiles will be pictured on the same panel.
Note
If by is specified (and level=0 is set), a legend is also added in the plot reporting covariate(s) name and value affecting the segmented relationship. Set pos.leg=TRUE to have no legend. On the other hand, use text.leg to add legend reporting the covariate baseline values.
Warning
All the functions for segmented mixed models (*.segmented.lme) are still at an experimental stage