##Codes for Estimation Plots {#plotting-section}
In this section we provide some example codes for the plotting the
time-varying estimations. plot
function can be directly
applied for the fitted object. In the case users want
data("ExampleData")
z <- ExampleData$x
time <- ExampleData$time
event <- ExampleData$event
fit.tv <- coxtv(z = z, event = event, time=time)
pcancer_beta_cancer_colon_cancerall = ggplot(data=beta_cancer_colon_cancerall, aes(x=time)) +
geom_line(aes(y=age_50, color='<50', linetype = '<50'),size = 0.9) +
geom_ribbon(aes(ymin = age_50_low, ymax = age_50_up), fill = "blue", alpha = 0.2) +
geom_line(aes(y=age_50_59, color='50-59', linetype = '50-59'),size = 0.9) +
geom_ribbon(aes(ymin = age_50_59_low, ymax = age_50_59_up), fill = "orange", alpha = 0.2) +
geom_line(aes(y=age_70, color='70+', linetype = '70+'),size = 0.9) +
geom_ribbon(aes(ymin = age_70_low, ymax = age_70_up), fill = "red", alpha = 0.2) +
geom_line(aes(y=constant, color='60-69', linetype = '60-69')) +
ggtitle("Cancer Death, Colon") +
scale_x_continuous(name='Years since diagnosis', limits=c(0,12), breaks = c(seq(0,12,2))) +
scale_y_continuous(name='Hazard Ratio (log-scale)', limits=c(-2.4,1.7), breaks=log(c(0.2,0.33,0.5,1,2,4)), labels = c(0.2,0.33,0.5,1,2,4)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
scale_color_manual(name='Age at diagnosis', values = c('<50'='blue', '50-59'='orange', "60-69" = "black", '70+'='red')) +
scale_linetype_manual(name='Age at diagnosis', values = c('<50'= 2, '50-59'= 3, "60-69" = 1, '70+'= 6)) +
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
theme(text= element_text(size=14)) + theme(axis.text= element_text(size=14)) +
theme(axis.title.y = element_text(margin= margin(t=0, r=10, b=0, l=0))) +
theme(legend.title = element_text(size=18), legend.text = element_text(size=16), legend.key.width = unit(2, 'cm')) +
theme(plot.title = element_text(size=14))
pcancer_beta_cancer_colon_cancerall