Hfunctions <- function(times1,d1,R1,n,times2,d2,R2,m,points,eta=1,lam){ #### This function computes the check-functions for 2 samples EL #### under several equality constraints. #### times12, d12, R12 --- the 2 sample observations, required inputs. #### The times12 should be ordered. d/R must be < 1, if the last value #### of (d/R) is 1, then delete it!!! #### points, --- a set of given t's used to get constraints. The #### constraints are: 1-F(t's) = [1-G(t's)]^eta . #### We assume min(times12) < points < max(times12).Last changed 6/25/2001 d12 <- c(d1, d2) R12 <- c(R1, R2) w012 <- d12/R12 # the Nelson-Aalen, unconstrained max location u012 <- log(1-w012) N<-n+m A21 <- outer(times1, points, FUN="<=") A22 <- outer(times2, points, FUN="<=") A2 <- rbind(A21, - eta*A22) # the constrain matrix if(length(lam)!=length(points)) stop("the length of lam not compatible") v <- d1/(R1+N*crossprod(lam, t(A21)) ) u <- d2/(R2-eta*N*crossprod(lam, t(A22)) ) u12 <- c(log(1-v), log(1-u)) return(u12 %*% A2) }