plot.stepmented: Plot method for stepmented objects

View source: R/plot.stepmented.r

plot.stepmentedR Documentation

Plot method for stepmented objects

Description

Takes a fitted stepmented object returned by stepmented() and plots (or adds) the fitted piecewise constant lines for the selected stepmented term.

Usage

## S3 method for class 'stepmented'
plot(x, term, add = FALSE, res = TRUE, interc = TRUE, 
    add.fx = FALSE, psi.lines = TRUE, link=FALSE, surf=FALSE, ...)

Arguments

x

a fitted stepmented object.

term

the stepmented variable having the piece-wise constant relationship to be plotted. If there is a single stepmented variable in the fitted model x, term can be omitted.

add

when TRUE the fitted lines are added to the current device.

res

when TRUE the fitted lines are plotted along with corresponding partial residuals.

interc

if TRUE the computed components include the model intercept (if it exists).

add.fx

logical. If TRUE and the object fit also includes an additional term for the same stepmented variable, the plot also portrays such ‘additional’ term.

psi.lines

if TRUE vertical lines corresponding to the estimated changepoints are also drawn

link

if FALSE the fitted lines (and possibily the residuals) are reported on the response scale. Ignored if the fit object x is not a glm-like fit.

surf

if the object fit x includes 2 stepmented covariates (x1 and x2, say) with relevant estimated breakpoints, surf=TRUE will draw on the plane x1-x2 the areas splitted according to the estimated breakpoints with corresponding estimated means superimposed.

...

other graphics parameters to pass to plotting commands: ‘col’, ‘lwd’ and ‘lty’ (that can be vectors and are recycled if necessary, see the example below) for the fitted piecewise constant lines; ‘ylab’, ‘xlab’, ‘main’, ‘sub’, ‘cex.axis’, ‘cex.lab’, ‘xlim’ and ‘ylim’ when a new plot is produced (i.e. when add=FALSE); ‘pch’ and ‘cex’ for the partial residuals (when res=TRUE, res.col is for the color).

Details

Produces (or adds to the current device) the fitted step-function like relationship between the response and the selected term. If the fitted model includes just a single ‘stepmented’ variable, term may be omitted. If surf=TRUE, and res=TRUE the point widths are proportional to the partial residual values.

Value

None.

Author(s)

Vito M. R. Muggeo

See Also

See Also as stepmented

Examples


#Following code in stepmented..
## Not run: 

par(mfrow=c(1,3))

plot(os,"x")
plot(os,"z")
plot(os,"z", add.fx=TRUE, psi.lines=FALSE ) 
lines(os, "z")

#display the 'surface'
par(mfrow=c(1,2))
plot(os, surf=TRUE, col=1, res.col=2)
plot(os, surf=TRUE, lty=2)

## End(Not run)


segmented documentation built on Nov. 28, 2023, 1:07 a.m.