plot.gcrq: Plot method for gcrq objects

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plot.gcrq.R

Description

Displaying the estimated growth charts from a gcrq fit.

Usage

1
2
3
4
5
6
## S3 method for class 'gcrq'
plot(x, term=NULL, add = FALSE, res = FALSE, conf.level=0, interc=TRUE, 
    legend = FALSE, select.tau, deriv = FALSE, cv = FALSE, transf=NULL, 
    lambda0=FALSE, shade=FALSE, overlap=NULL, rug=FALSE, n.points=100, 
    edf.ylab=NULL, overall.eff=TRUE, grid=NULL, smoos=NULL, split=FALSE, shift=NULL, 
    type=c("sandw","boot"), ...)

Arguments

x

a fitted "gcrq" object.

term

the smooth variable name entering the model via ps. Relevant fitted quantile curves (as specified by select.tau) will be plotted. If NULL, all smooth terms are plotted according to the split argument.

interc

Should the smooth term be plotted along with the intercept (provided it is included in the model)? If the smooth term is a varying coefficient, interc refers to its intercept, and not the overall model intercept (see argument shift to plot a VC smooth curve with model intercept). 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’.

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 Xj are defined as
fitted values corresponding to Xj + 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 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.

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 curve is 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

If provided and different from NULL, it represents the abscissa value (on the covariate scale) where the legend (i.e. the probability values) of each curve is set. If unspecified (i.e. overlap=NULL), the legend is placed outside the fitted lines on the right side. Ignored if legend=FALSE.

rug

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

n.points

numeric. Number of values used to plot the fitted curves. Large values provide smoother curves.

edf.ylab

Should the edf value to be reported as y label? If NULL, edf.ylab is set to TRUE only if there is a single quantile curve to be plotted.

overall.eff

logical. If the smooth term has been called via ps(.., decompose=TRUE), by specifying overall.eff=TRUE the overall smooth effect is drawn.

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 smooth terms 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 to be added to the curve(s) to be plotted. Default is NULL which means the 'model intercept' for VC smooth term and 0 otherwise. It can be useful to plot the VC term accounting for the model intercept.

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 for the legend (if legend=TRUE);
cex.p, col.p, and pch.p for the points (if res=TRUE).

Details

Takes a "gcrq" object and diplays the fitted quantile curves. 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.

Value

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

Author(s)

Vito M. R. Muggeo

See Also

gcrq, predict.gcrq

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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 March 27, 2021, 9:06 a.m.