Learn R Programming

kmc (version 0.2-2)

kmc.solve: Calculate NPMLE with constriants for right censored data

Description

This function calculate the Kaplan-Meier estimator with mean constraints recursively. $$El(F)=\prod_{i=1}^{n}(\Delta F(T_i))^{\delta_i}(1-F(T_i))^{1-\delta_i}$$ with constraints $$\sum_i g(T_i)\Delta F(T_i)=0,\quad,i=1,2,...$$ It uses Lagrange multiplier directly.

Usage

kmc.solve(x, d, g, em.boost = T, using.num = T, using.Fortran =
                 T, using.C = F, tmp.tag = T, rtol = 1e-09, control =
                 list(nr.it = 20, nr.c = 1, em.it = 3),...)

Arguments

x
Possitive time
d
Status, 0: right censored; 1 uncensored
g
list of contraint functions. It should be a list of functions list(f1,f2,...)
em.boost
logical asking whether to use EM to get the initial value, default=TRUE. See 'Details' for EM control.
using.num
logical asking whether to use numeric derivative in iterations, default=TRUE.
using.Fortran
logical asking whether to use Fortran in root solving, default=F.
using.C
logical asking whether to use Rcpp in iteraruib, default=T. This option will promote the performance of KMC algorithm. Development version works on one constraint only, otherwise it will generate a Error information. It won't work on using.num=F.
tmp.tag
Development version needs it, keep it as TRUE.
rtol
Tolerance used in rootSolve(multiroot) package, see 'rootSolve::multiroot'.
control
nr.it controls max iterations allowed in N-R algorithm default=20, nr.c is the scaler used in N-R algorithm default=1,em.it is max iteration if use EM algorithm (em.boost) to get the initial value of lambda, default=3.
...
Unspecified yet.

Value

  • a list with the following components:
  • loglik.halog empirical likelihood without constraints
  • loglik.h0log empirical likelihood with constraints
  • "-2llr"-2 Log empirical likelihood
  • phat$$\Delta F(T_i)$$
  • pvaluep-value of the test
  • dfDegree(s) of freedom. It equals the number of constraints.
  • lambdaThe lambda is the Lagrangian multiplier described in reference.

Details

The development version won't check the constraint is proper or not. Besides, an extrordinary large number will be generated when numeric method/constraint(s) fails.

References

Zhou, M. and Yang, Y. (2015). A recursive formula for the Kaplan-Meier estimator with mean constraints and its application to empirical likelihood Computational Statistics Online ISSN 1613-9658.

See Also

plotkmc2D, print.kmcS3.

Examples

Run this code
x <- c( 1, 1.5, 2, 3, 4.2, 5.0, 6.1, 5.3, 4.5, 0.9, 2.1, 4.3) # positive time
d <- c( 1,   1, 0, 1, 0, 1, 1, 1, 1, 0, 0,   1)               # status censored/uncensored

#################
# dim =1
#################

f<-function(x) { x-3.7}                                       # \sum f(ti) wi ~ 0
g=list( f=f) ;                                                #define constraint as a list

kmc.solve( x,d,g) ;                                           #using default
kmc.solve( x,d,g,using.C=TRUE) ;                              #using Rcpp

#################
# dim =2
#################

myfun5 <- function( x)  {
 x^2-16.5
}
g=list( f1=f,f2=myfun5) ;                                     #define constraint as a list
kmc.solve( x,d,g) ->re0;
print(re0);                                                   #print method, plain ASCII
print(re0,5);                                                 #print method, digits=5,plain ASCII
print(re0,type='md');                                         #print method, output GIT Markdown
#summary(re0) is under developing.

Run the code above in your browser using DataLab