This function takes the output of sim.survdata
and plots the baseline
failure PDF, the baseline failure CDF, the baseline survivor function, and the baseline hazard
function that were generated and used to simulate the data. The function also produces histograms
of the simulated durations, the linear predictor, and the exponentiated linear predictor.
survsim.plot(survsim, type = "both", bins = 30, df = 1)
An object of class "simSurvdata
" output by sim.survdata
If type="baseline"
the function plots the baseline functions.
If type="hist"
the function plots the histograms. If type="both"
the function
plots both the baseline functions and the histograms, aligned in a 2 x 1 array
The number of bins to draw in each histogram. Ignored if type="baseline"
If survsim
is generated by a call to sim.survdata
in which
num.data.frames
is greater than 1, the output is a list of iterated simulation output. In this case,
df
specifies the particular simulation iteration for which to produce visualizations
A figure of class "gg"
and "ggplot"
if type="baseline"
or type="hist"
, and of
classes "gtable"
, "gTree"
, "grob"
, and "gDesc"
if type="both"
.
A challenge that can limit research to develop methods to analyze survival data is that a
pre-specified baseline hazard function must be used to generate simulated data, which contradicts the
Cox proportional hazards model's feature of circumventing the hazard to estimate coefficients. The
flexible-hazard method developed by Harden and Kropko (2018) and implemented in sim.survdata
allows for the simulation of duration data without assuming a particular parametric form for hazard.
survsim.plot
is useful for visualizing the baseline functions, including hazard, that result from
this algorithm for a particular draw of simulated duration data. The function uses ggplot
to create line plots for the baseline failure PDF, the baseline failure CDF, the baseline survivor function,
and the baseline hazard function over time. The baseline functions and time are attributes of the
sim.survdata
output.
Harden, J. J. and Kropko, J. (2018). Simulating Duration Data for the Cox Model. Political Science Research and Methods https://doi.org/10.1017/psrm.2018.19
# NOT RUN {
simdata <- sim.survdata(N=1000, T=100, num.data.frames=1)
survsim.plot(simdata)
# }
Run the code above in your browser using DataLab