simGG.simlinear {simPH} | R Documentation |
Plot simulated linear, non-time interacted quantities of interest from Cox Proportional Hazards Models
Description
simGG.simlinear
uses ggplot2 to plot the quantities of interest
from simlinear
objects, including relative hazards, first
differences, hazard ratios, and hazard rates.
Usage
## S3 method for class 'simlinear'
simGG(
obj,
from = NULL,
to = NULL,
rug = TRUE,
rug_position = "identity",
xlab = NULL,
ylab = NULL,
title = NULL,
method = "auto",
spalette = "Set1",
legend = "legend",
leg.name = "",
lcolour = "#2B8CBE",
lsize = 1,
pcolour = "#A6CEE3",
psize = 1,
alpha = 0.2,
type = "ribbons",
...
)
Arguments
obj |
a |
from |
numeric time to start the plot from. Only relevant if
|
to |
numeric time to plot to. Only relevant if
|
rug |
logical indicating whether or not to include a rug plot showing
the distribution of values in the sample used to estimate the |
rug_position |
character string. The position adjustment to use for
overlapping points in the rug plot. Use |
xlab |
a label for the plot's x-axis. |
ylab |
a label of the plot's y-axis. The default uses the value of
|
title |
the plot's main title. |
method |
what type of smoothing method to use to summarize the center of the simulation distribution. |
spalette |
colour palette for when there are multiple sets of
comparisons to plot. Default palette is |
legend |
specifies what type of legend to include (if applicable).
The default is |
leg.name |
name of the legend (if applicable). |
lcolour |
character string colour of the smoothing line. The default is
hexadecimal colour |
lsize |
size of the smoothing line. Default is 1. See
|
pcolour |
character string colour of the simulated points or ribbons
(when there are not multiple sets of simulations). Default is hexadecimal
colour |
psize |
size of the plotted simulation points. Default is
|
alpha |
numeric. Alpha (e.g. transparency) for the points, lines, or
ribbons. Default is |
type |
character string. Specifies how to plot the simulations. Can be
|
... |
Additional arguments. (Currently ignored.) |
Details
Uses ggplot2 to plot the quantities of interest from
simlinear
objects, including relative hazards, first differences,
hazard ratios, and hazard rates. If there are multiple strata, the
quantities of interest will be plotted in a grid by strata.
Note: A dotted line is created at y = 1 (0 for first difference), i.e. no
effect, for time-varying hazard ratio graphs. No line is created for hazard
rates.
Value
a gg
ggplot
class object
References
Gandrud, Christopher. 2015. simPH: An R Package for Illustrating Estimates from Cox Proportional Hazard Models Including for Interactive and Nonlinear Effects. Journal of Statistical Software. 65(3)1-20.
Licht, Amanda A. 2011. ”Change Comes with Time: Substantive Interpretation of Nonproportional Hazards in Event History Analysis.” Political Analysis 19: 227-43.
Keele, Luke. 2010. ”Proportionally Difficult: Testing for Nonproportional Hazards in Cox Models.” Political Analysis 18(2): 189-205.
Carpenter, Daniel P. 2002. ”Groups, the Media, Agency Waiting Costs, and FDA Drug Approval.” American Journal of Political Science 46(3): 490-505.
See Also
coxsimLinear
, simGG.simtvc
, and
ggplot2
Examples
# Load survival package
library(survival)
# Load Carpenter (2002) data
data("CarpenterFdaData")
# Estimate basic model
M1 <- coxph(Surv(acttime, censor) ~ prevgenx + lethal +
deathrt1 + acutediz + hosp01 + hhosleng +
mandiz01 + femdiz01 + peddiz01 + orphdum +
vandavg3 + wpnoavg3 + condavg3 + orderent +
stafcder, data = CarpenterFdaData)
# Simulate and plot Hazard Ratios for stafcder variable
Sim1 <- coxsimLinear(M1, b = "stafcder",
Xj = c(1237, 1600),
Xl = c(1000, 1000),
qi = "Hazard Ratio",
spin = TRUE, ci = 0.99)
simGG(Sim1, method = 'lm', rug_position = 'jitter')
simGG(Sim1, rug_position = 'jitter')
## Not run:
# Simulate and plot Hazard Rate for stafcder variable
Sim2 <- coxsimLinear(M1, b = "stafcder", nsim = 100,
qi = "Hazard Rate",
Xj = c(1237, 1600))
simGG(Sim2, type = 'points')
simGG(Sim2, type = 'lines')
## End(Not run)