DrawPlot: Draw Single Plot

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

View source: R/DrawPlot.R

Description

This function draws a single time-series plot on the active graphics device.

Usage

1
2
DrawPlot(d, model, plim = c(0.1, 0.9), xlim = NULL, ylim = NULL,
  main = NULL, ylab = "")

Arguments

d

data.frame. Observations, where the first and second column is of class Date and Surv, respectively. The Surv component is of type interval and should not contain right-censored data.

model

survreg. Survival regression model

plim

numeric. Percentile limits defining the confidence band of the regression model.

xlim

Date. The x limits of plot.

ylim

numeric. The y limits of plot.

main

character. Main plot title

ylab

character. Label for y axis.

Details

Uncensored data is drawn as points. Left- and interval-censored data is drawn as vertical lines with short-horizontal lines at the interval bounds. Note that the lower bound of left-censored data is placed at zero. The 50th percentile of the regression model is drawn as a curved line. The confidence band is drawn as a solid polygon.

Value

Used for the side-effect of a new plot generated.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

See Also

RunAnalysis, predict.survreg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Create time-series data set with uncensored, left-censored, and interval-censored data
n <- 30
x <- as.Date(sort(sample(1:1000, n)), origin = as.Date("1992-02-15"))
time1 <- runif(n, min = 0, max = 100)
time2 <- time1 + runif(n, min = 0, max = 10)
time1[sample(1:n, 10)] <- NA
idxs <- sample(1:n, 10)
time1[idxs] <- time2[idxs]
y <- survival::Surv(time1, time2, type = "interval2")
d <- data.frame(x, y)

# Fit the data with a regression model
model <- survival::survreg(y ~ x, data = d)

# Plot the data and regression model
DrawPlot(d, model, plim = c(NA, 0.8), main = "Title", ylab = "Value")

jfisher-usgs/Trends documentation built on May 19, 2019, 7:16 a.m.