Learn R Programming

carx (version 0.7.1)

plot.carx: Plot a fitted carx object

Description

plot.carx plots a fitted carx object.

Usage

# S3 method for carx
plot(x, FUN = identity, xAxisVar = NULL, xlab = "Index",
  ylab = "Response", ...)

Arguments

x

a fitted carx object.

FUN

an optional function to be applied to the transform the responses before plotting. This is useful for plotting the data on the original scale if the fitted carx object is based on transformed responses. For instance, if the carx object was fitted with log transformed responses, setting FUN to exp renders the original response data to be plotted. Default = NULL.

xAxisVar

an optional vector to be plotted as the x variable. Default = NULL corresponds to doing a time series plot.

xlab

the label of the x axis. Default = "Index".

ylab

the label of the y axis. Default = "Response".

...

other parameters supplied to the generic function plot.

Value

None. A plot will be displayed.

Details

The y axis will be the values related to the response. If the fitted object contains the data and censored information in a cenTS object, the function will take advantage of the plot function for a cenTS object and superimpose the plot of the fitted values. Otherwise, the plot function will try to produce a plot similar to the previous case, while the x axis can be supplied by the user through xAxisVar, which must be ordinal and increasing.

Examples

Run this code
# NOT RUN {
#case 1: plot with cenTS object in the object, note that the x-axis is in date.
dat = carxSimCenTS(nObs=100,seed=0)
mdl <- carx(y~X1+X2-1,data=dat, p=2, CI.compute = FALSE)
#use default settings
plot(mdl)

#case 2: plot without cenTS object in the object, note that the x-axis is a vector of numbers.
dat = carxSim(nObs=100,seed=0)
mdl <- carx(y=dat$y, x=dat[,c("X1","X2")], ci=dat$ci, lcl=dat$lcl, ucl=dat$ucl, p=2)
#or simply call
mdl <- carx(y~X1+X2-1,data=dat, p=2, CI.compute = FALSE)
plot(mdl)
# }

Run the code above in your browser using DataLab