Takes a fitted segmented.lme
object returned by segmented.lme()
and plots (or adds)
the fitted broken-line relationship for the segmented term.
# S3 method for segmented.lme
plot(x, level=1, id = NULL, res = TRUE, pop = FALSE, 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, ...)
A single or multiple (depending on level
and id
) plot showing the fitted segmented profiles.
Object of class "segmented.lme"
An integer giving the level of grouping to be used when computing the segmented relationship(s). level=0
means 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.
A scalar or vector meaning which subjects profiles have to be drawn. If NULL
(default) all profiles are drawn. Ignored if level=0
.
If TRUE
, the data points are also drawn. Ignored if level=0
.
if TRUE
, the fitted segmented relationships based on fixed-effects only is also portrayed. Ignored if level=0
.
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'.
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'.
a vector to be passed to par(mfrow=c(..))
for plotting multiple panels (should be coherent with length(id)
). If missing, it is computed automatically depending on length(id)
. Type n.plot=1
to draw all the segmented profiles on the same panel.
a character ('topright', 'topleft',...) meaning the location of the legend. Set NULL
for no legend.
logical, if TRUE
a vertical dashed segment is added to emphasize the breakpoint location.
logical, if FALSE
points, rather than lines, are used to portray the segmented relationships.
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 variables sex
and z
affect the segmented relationship. Effective only if level=0
.
If TRUE
the (fixed-effect) fitted segmented relationship is added to the current plot. Effective only if level=0
.
The confidence level for pointwise confidence intervals. Effective only if level=0
.
If TRUE
, the level 0 segmented relationship is computed with the model intercept. Effective only if level=0
.
The fixed effects covariance matrix. If NULL
, it is computed by vcov.segmented.lme()
. Effective only if level=0
.
If TRUE
(and conf.level>0
) the area within the pointiwise CIs is shaded. Effective only if level=0
.
Possible coefficient names to be removed before computing the segmented relationship (E.g. the group-specific intercept.).
If specified (and pos.leg
has been also specified), it is the legend text. Effective only if level=0
.
If pos.leg
is different from NULL
, id.name=TRUE
will portray the cluster variable name along the value. Namely id.name=TRUE
leads to 'country = italy' on each panel, while id.name=FALSE
to 'italy'.
additional arguments, such as ylab
,xlab
, ylim
and xlim
; l.col,l.lwd,l.lty
(for the fitted individual lines - can be vectors and will be recycled); p.col, p.lwd, p.lty
for the population line (if pop=TRUE
); col, cex, pch
for the data points (if res=TRUE
); t.col
for the legend color, if pos.leg
is not NULL
. If level=0
and conf.level>0
, lty
and lwd
can be vectors.
Vito Muggeo
All the functions for segmented mixed models (*.segmented.lme) are still at an experimental stage
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.
segmented.lme
if (FALSE) {
#continues example from segmented.lme
plot(os, yscale=-1) #different y-scales
plot(os2, n.plot=1, l.col=2:6, l.lwd=2) #all segmented profiles on the same plot
}
Run the code above in your browser using DataLab