plot.gcrq: Plot method for gcrq objects

View source: R/plot.gcrq.R

plot.gcrqR Documentation

Plot method for gcrq objects

Description

Displaying the estimated growth charts from a gcrq fit.

Usage

## S3 method for class 'gcrq'
plot(x, term=NULL, add = FALSE, res = FALSE, conf.level=0, axis.tau=FALSE, 
   interc=TRUE, se.interc=FALSE, legend = FALSE, select.tau, deriv = FALSE, 
   cv = FALSE, transf=NULL, lambda0=FALSE, shade=FALSE, overlap=NULL, rug=FALSE, 
   overall.eff=TRUE, grid=NULL, smoos=NULL, split=FALSE, shift=0, type=c("sandw","boot"), 
   ...)

Arguments

x

a fitted "gcrq" object.

term

the variable name or its index in the formula entering the model. Can be vector. Both linear ad spline terms (i.e. included in the model via ps) can be specified and relevant fitted quantile curves (as optionally specified by select.tau) will be plotted. If the model includes both linear and smooth terms, the smooth terms are counted and drawn *first*: therefore if the model formula is y~z+ps(x), term=1 refers to the smooth term. If NULL, all smooth terms are plotted according to the split argument. If the model includes multiple quantile curves and axis.tau=TRUE, term=1 refers to the model intercept (if in the model). The variable name should be reported within 'ps()', e.g. 'ps(age)' regardless of additional arguments specified in ps.

interc

Should the smooth term be plotted along with the model intercept (provided it is included in the model)? Of course such argument is ignored if the smooth term has been called via ps(, dropc=FALSE) and the plot always includes implicitly the ‘intercept’. Note that interc=TRUE is requested to display the noncrossing curves (if multiple quantile curves are being plotted).

se.interc

logical. If TRUE the standard errors of fitted quantile curves account for uncertainty of the model intercept (provided it is included in the model). If FALSE, then the uncertainty relates purely to the (usually centred) smooth itself. Ignored if conf.level=0.

add

logical. If TRUE the fitted quantile curves are added on the current plot.

res

logical. If TRUE ‘partial residuals’ are also displayed on the plot. Borrowing terminology from GLM, partial residuals for covariate X_j are defined as
fitted values corresponding to X_j + residuals (from the actual fit).
If there is a single covariate, the partial residuals correspond to observed data. If multiple quantile curves have been estimated, the fitted values coming from the ‘middle’ quantile curve are employed to compute the partial residuals. ‘Middle’ means 'corresponding to the \tau_k closest to 0.50'. I don't know if that is the best choice.

conf.level

logical. If larger than zero, pointwise confidence intervals for the fitted quantile curve are also shown (at the confidence level specified by conf.level). Such confidence intervals are independent of the possible intercept accounted for via the intercept argument. See type to select different methods (bootstrap or sandwich) to compute the standard errors.

axis.tau

logical. If TRUE, the estimated coefficient term is plotted against the probability values. This graph could be useful if the model has been estimated at several tau values.

legend

logical. If TRUE a legend is drawn on on the right side of the plot.

select.tau

an optional numeric vector to draw only some of the fitted quantiles. Percentile values or integers 1 to length(tau) may be supplied.

deriv

logical. If TRUE the first derivative of the fitted curves are displayed.

cv

logical. If TRUE and the "gcrq" object contains a single smooth term wherein lambda has been selected via CV, then the cross-validation scores against the lambda values are plotted.

transf

An optional character string (with "y" as argument) meaning a function to apply to the predicted values (and possibly residuals) before plotting. E.g. "(exp(y)-0.1)". If NULL (default) it is taken as the inverse of function transf (*if*) supplied in gcrq. See argument "transf" in gcrq(). If transf has been specified in gcrq(), use transf="y" to force plotting on the transformed scale, i.e. without back transforming.

lambda0

logical. If cv=TRUE, should the CV plot include also the first CV value? Usually the first CV value is at lambda=0, and typically it is much bigger than the other values making the plot not easy to read. Default to FALSE not to display the first CV value in the plot.

shade

logical. If TRUE and conf.level>0, the pointwise confidence intervals are portrayed via shaded areas.

overlap

NULL or numeric (scalar or vector). If provided and different from NULL, it represents the abscissa values (on the covariate scale) where the legends (i.e. the probability values) of each curve are set. It will be recycled, if its length differs from the number of quantile curves. If unspecified (i.e. overlap=NULL), the legends are placed outside the fitted lines on the right side. If specified, legend=TRUE is implicitly assumed.

rug

logical. If TRUE, the covariate distribution is displayed as a rug plot at the foot of the plot. Default to FALSE.

overall.eff

logical. If the smooth term has been called via ps(.., decom=TRUE), by specifying overall.eff=TRUE the overall smooth effect is drawn, otherwise only the penalized part is portrayed (always without intercept).

grid

if provided, a grid of horizontal and vertical lines is drawn. grid has to be a list with the following components x,y,col,lty,lwd. If x (y) is a vector, the vertical (horizontal) lines are drawn at these locations. If x (y) is a scalar, the vertical (horizontal) lines are drawn at x (y) equispaced values. col, lty,lwd refer to the lines to be drawn.

smoos

logical, indicating if the residuals (provided that res=TRUE) will be drawn using a smoothed scatterplot. If NULL (default) the smoothed scatterplot will be employed when the number of observation is larger than 10000.

split

logical. If there are multiple terms (both smooth and linear) and split=TRUE, plot.gcrq() tries to split the plotting area in 2 columns and number of rows depending on the number of smooths. If split=FALSE, the plots are produced on the current device according to the current graphics settings. Ignored if there is single smooth term.

shift

Numerical value(s) to be added to the curve(s) to be plotted. If vector with length equal to the number of quantile curves to plot, the shift[j] is added to the jth quantile curve.

type

If conf.level>0, which covariance matrix should be used to compute and to portray the pointwise confidence intervals? 'boot' means case-resampling bootstrap (see n.boot in gcrq(), 'sandw' mean via the sandwich formula.

...

Additional graphical parameters:
xlab, ylab, ylim, and xlim (effective when add=FALSE);
lwd, lty, and col for the fitted quantile lines; col<0 means color palette for the different curves;
cex and text.col for the legend (if legend=TRUE or overlap is specified);
cex.p, col.p, and pch.p for the points (if res=TRUE).
When axis.tau=TRUE, all arguments accepted by plot(), points(), matplot(), and matpoints() but pch, type, xlab, ylab, lty.

Details

Takes a "gcrq" object and diplays the fitted quantile curves as a function of the covariate specified in term. If conf.level>0 pointwise confidence intervals are also displayed. When the object contains the component cv, plot.gcrq can display cross-validation scores against the lambda values, see argument cv. If a single quantile curve is being displayed, the default 'ylab' includes the relevant edf value (leaving out the basis intercept). If axis.tau=TRUE and the fit includes several quantile curves, plot.gcrq() portrays the estimated coefficients versus the probability values. If term refers to a categorical variable, the point estimates against the categories are plotted (conf.level is ignored).

Value

The function simply generates a new plot or adds fitted curves to an existing one.

Note

Plotting non-crossing curves could depend on the arguments 'interc' and 'shift', in turn depending on how the model has been specified. Take care about that!

Author(s)

Vito M. R. Muggeo

See Also

gcrq, predict.gcrq

Examples


## Not run: 
## use the fits from ?gcrq
#The additive model
plot(o, res=TRUE, col=2, conf.level=.9, shade=TRUE, split=TRUE)


par(mfrow=c(2,2))
plot(m5, select.tau=c(.1,.5,.9), overlap=0.6, legend=TRUE)
plot(m5, grid=list(x=8,y=5), lty=1) #a 8 times 5 grid.. 
plot(m7, cv=TRUE) #display CV score versus lambda values
plot(m7, res=TRUE, grid=list(x=5, y=8), col=4) #fitted curves at the best lambda value


## End(Not run)


quantregGrowth documentation built on July 9, 2023, 6:06 p.m.