inst/doc/WR_test_rec.R

## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval=F-------------------------------------------------------------------
#  obj<-WRrec(ID,time,status,trt)

## ----setup--------------------------------------------------------------------
library(WR)
head(hfaction_cpx9)

## -----------------------------------------------------------------------------
## simplify the dataset name
dat<-hfaction_cpx9
## comparing exercise training to usual care by LWR, FWR, and NWR
obj<-WRrec(ID=dat$patid,time=dat$time,status=dat$status,
          trt=dat$trt_ab,strata=dat$age60,naive=TRUE)
## print the results
obj

## -----------------------------------------------------------------------------
######################################
## Remove recurrent hospitalization ##
######################################
## sort dataset by patid and time
o<-order(dat$patid,dat$time)
dat<-dat[o,]
## retain only the first hospitalization
datHF<-dat[!duplicated(dat[c("patid","status")]),]
head(datHF)

## -----------------------------------------------------------------------------
## Perform the standard win ratio test
objSWR<-WRrec(ID=datHF$patid,time=datHF$time,status=datHF$status,
          trt=datHF$trt_ab,strata=datHF$age60)
## print the results
objSWR

Try the WR package in your browser

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

WR documentation built on Nov. 27, 2021, 1:06 a.m.