
#replace this directory with the one of the unzipped files
setwd("")


#install package "WR" from GitHub
install.packages("devtools")
library(devtools)
install_github("lmaowsic/Win-ratio/WR")
# or install it manually from "./R fun/WR_0.1.0.tar.gz"

data=read.table("./HF-ACTION.txt")

id=data[,1]
time=data[,2]
status=data[,3]
Z=as.matrix(data[,4:ncol(data)])


library(WR)
# fit the priority-adjusted PW model
# using the pwreg function
obj=pwreg(time=time,status=status,Z=Z,ID=id)
obj

#compute the standardized score processes
score.proc.obj=score.proc(obj)

#plot the standardized score processes
par(mfrow=c(1,2))
plot(score.proc.obj,1,xlab="Time (months)",cex.main=1.5,cex.lab=1.5,cex.axis=1.5,lwd=2)
plot(score.proc.obj,2,xlab="Time (months)",cex.main=1.5,cex.lab=1.5,cex.axis=1.5,lwd=2)




