Learn R Programming

transform.hazards (version 0.1.1)

pluginEstimate: SDE plugin estimator solver

Description

Calculates recursive estimator for given hazard estimates, integrand function and gradients.

Usage

pluginEstimate(n, hazMatrix, F_fun, JacobianList, X0, V0, isLebesgue = NULL)

Value

list containing the parameter estimate X, and its covariance estimates V/n

Arguments

n

Total number of indiivduals

hazMatrix

Matrix consisting of hazards(rows) and their increments(columns) along the same time scale

F_fun

Integrand function F = (F_1,F_2,...) for the differential equation system

JacobianList

The Jacobian matrices of F_1, F_2, ... organized in a list

X0

Matrix containing initial values for the parameter

V0

Matrix containing initial values for the variance

isLebesgue

(Optional, to improve efficientcy) Provide the index of A (e.g. 2) that is a regular dt integral, i.e. not a cumulative hazard.

Author

Pål Christie Ryalen p.c.ryalen@medisin.uio.no

References

Ryalen, P.C., Stensrud, M.J., Røysland, K.: Transforming cumulative hazards, arXiv, to appear in Biometrika 2018.

Examples

Run this code
###############################################################
#########################  Survival  ##########################
###############################################################
library(timereg)

n <- 100
dfr <- data.frame(to = rexp(n,1),from=0,event=1)

fit <- survfit(Surv(from,to,event==1)~1,data=dfr)

times <- fit$time
dN <- fit$n.event
Y <- fit$n.risk
Y[1] <- n

dA <- matrix(dN/Y,nrow=1,ncol=length(dN))

# Function specification
F_fun_Survival <- function(x)-matrix(x,1,1)
JacobianListSurvival <- list(function(x)-matrix(1,1,1))
X0_Survival <- matrix(1,1,1)
V0_Survival <- matrix(0,1,1)

paramEst_survival <- pluginEstimate(
  n,dA,F_fun_Survival,JacobianListSurvival,X0_Survival,V0_Survival
)

KM <- cumprod(1 - dA)
Greenwood <- KM^2 * cumsum(dA^2)

plot(
  times,paramEst_survival$X,type="s",main="SDE plugin survival estimates",
  ylab="",xlab="time"
)
lines(times,paramEst_survival$X + 1.96*sqrt(paramEst_survival$covariance[1,1,]),type="s")
lines(times,paramEst_survival$X - 1.96*sqrt(paramEst_survival$covariance[1,1,]),type="s")
lines(seq(0,10,length.out=100),exp(-seq(0,10,length.out=100)),col=2)
legend("topright",c("SDE plugin estimates","Exact"),lty=1,col=c(1,2),bty="n")

plot(
  times,paramEst_survival$covariance,type="s",
  main="SDE plugin variance vs Greenwood variance",ylab="",xlab="time"
)
lines(times,Greenwood,type="s",col=4,lty=1)
legend("topright",c("SDE plugin estimates","Greenwood"),lty=1,col=c(1,4),bty="n")

#################################################################################
############ Competing risks and Cumulative incidence(two states) ###############
#################################################################################

n <- 200
x1 <- rexp(n,1)
x2 <- rexp(n,1.3)
to.states <- ifelse(x1

Run the code above in your browser using DataLab