inst/doc/ggforest-show-interactions-hazard-ratio.R

## ----include = FALSE--------------------------------------------------------------------------------------------------------------------------------
library(knitr)
opts_chunk$set(
	comment = "",
	message = FALSE,
	warning = FALSE,
	tidy.opts = list(
		keep.blank.line = TRUE,
		width.cutoff = 150
		),
	options(width = 150),
	eval = TRUE
)

## ----setup------------------------------------------------------------------------------------------------------------------------------------------
library(survminer)
library(survival)

## ---------------------------------------------------------------------------------------------------------------------------------------------------
res.cox <- coxph(Surv(time, status) ~ ph.karno * age, data=lung)
summary(res.cox, conf.int = FALSE)

## ----ggforest, fig.width=5, fig.height=4------------------------------------------------------------------------------------------------------------
ggforest(res.cox, data = lung)

## ---------------------------------------------------------------------------------------------------------------------------------------------------
lung$ph.karno_age <- lung$ph.karno * lung$age

## ---------------------------------------------------------------------------------------------------------------------------------------------------
res.cox2 <- coxph(Surv(time, status) ~ ph.karno + age + ph.karno_age, data = lung)
summary(res.cox2 , conf.int = FALSE)

## ----ggforest-with-interactions, fig.width=5, fig.height=4------------------------------------------------------------------------------------------
ggforest(res.cox2, data=lung)

Try the survminer package in your browser

Any scripts or data that you put into this service are public.

survminer documentation built on March 9, 2021, 5:07 p.m.